【发布时间】:2012-08-13 14:48:45
【问题描述】:
我在这里发现了几个类似的问题,但建议的答案不适合我。
所以错误是:
08-13 14:40:10.723: E/AndroidRuntime(630): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragments/com.example.fragments.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
我的 MainActivity 是:
package com.example.fragments;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
我的 xml 是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/listFragment"
android:layout_width="150dip"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
class="com.example.fragments.ListFragment" >
</fragment>
<fragment
android:id="@+id/detailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.fragments.DetailFragment" >
</fragment>
</LinearLayout>
非常感谢您对此问题的任何帮助
xx
【问题讨论】:
-
是您的应用中存在的 com.example.fragments.ListFragment 、 com.example.fragments.DetailFragment 类吗?
-
亲爱的 Nandeesh,是的,它们存在于项目文件夹中,并且位于包 com.example.fragments 中
标签: android android-fragments android-xml