加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于两个Fragment布局报错Error inflating class fragment的解决

发布时间:2020-12-16 06:37:01 所属栏目:百科 来源:网络整理
导读:xml源代码如下: LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:


xml源代码如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<FrameLayout
android:id="@+id/main_titles"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />


<FrameLayout
android:id="@+id/main_details"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="4" />


</LinearLayout>


运行后报错:android.view.InflateException: Binary XML file line #4: Error inflating class fragment


解决方法:在linearlayout中设置上下文

tools:context=".*********"

星号为调用两个fragment的Activity。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读