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


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。

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念