Error inflating class fragment 解决方案
今天在开发中使用代码控制fragment遇到了这样一个问题 Binary XML file line #13: Error inflating class fragment
下面说几种问题的可能情况
1.xml写错
如果你像我一样,写成了这样
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:id="@+id/content"/>
是不对的,应该使用FrameLayout,如果想要使用fragment,则必须指定。
2 包兼容的问题
请保证使用
import android.support.v4.app.Fragment;
另外也可以让你的Activity继承FragmentActivity 而不是Activity
import android.support.v4.app.FragmentActivity;
823

被折叠的 条评论
为什么被折叠?



