我使用Eclipse ADT制作了MasterActivity和DetailsActivity,我在手机和平板电脑上进行了测试,但是当我用另一台平板电脑测试时,我遇到了这个错误
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.website.softarge/solutions.SolutionListActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
我的代码:
public class SolutionListActivity extends FragmentActivity implements
SolutionListFragment.Callbacks {
...
// this line causes the error
setContentView(R.layout.activity_solution_list);
...
}
此代码必须调用此片段
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/solution_list"
android:name="solutions.SolutionListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".SolutionListActivity"
tools:layout="@android:layout/list_content" />
答案 0 :(得分:0)
检查失败的平板电脑的Android版本。我认为失败的平板电脑很可能是现有片段之前的版本(API Level 11,即Android 3.0.x或Honeycomb)。如果是这种情况,您将需要使用Android支持库,该库支持旧版Android中的片段。我敢打赌你有姜饼(2.3.x)或更早的平板电脑。