我在这里发现了几个类似的问题,但提出的答案不适合我。错误从xml中膨胀类别片段
所以,错误的是:
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 2012-08-13 15:14:05
亲爱的nandeesh,是的,他们目前在项目文件夹中,并在包com.example.fragments – Dennis 2012-08-13 16:04:08