我开发了多窗格应用程序。在升级 SDK 版本之前它工作正常。我安装了最新升级的 android 。然后它给出以下异常:
Android SDK 工具:22.0.5 版
08-05 14:17:13.750: E/AndroidRuntime(4234): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xont.hemas.controller/com.xont.hemas.controller.sale.SalesRouteFragment}: android.view.InflateException: Binary XML file line #69: Error inflating class fragment
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread.access$600(ActivityThread.java:128)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.os.Looper.loop(Looper.java:137)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread.main(ActivityThread.java:4514)
08-05 14:17:13.750: E/AndroidRuntime(4234): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 14:17:13.750: E/AndroidRuntime(4234): at java.lang.reflect.Method.invoke(Method.java:511)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-05 14:17:13.750: E/AndroidRuntime(4234): at dalvik.system.NativeStart.main(Native Method)
08-05 14:17:13.750: E/AndroidRuntime(4234): Caused by: android.view.InflateException: Binary XML file line #69: Error inflating class fragment
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.xont.hemas.controller.sale.SalesRouteFragment.onCreate(SalesRouteFragment.java:82)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.Activity.performCreate(Activity.java:4465)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
08-05 14:17:13.750: E/AndroidRuntime(4234): ... 11 more
08-05 14:17:13.750: E/AndroidRuntime(4234): Caused by: java.lang.IllegalStateException: Content view not yet created
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
08-05 14:17:13.750: E/AndroidRuntime(4234): at com.xont.hemas.controller.sale.ItemListFragment.onCreate(ItemListFragment.java:59)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.Fragment.performCreate(Fragment.java:1437)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:877)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
08-05 14:17:13.750: E/AndroidRuntime(4234): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
我的代码是:activity_item_list.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".sale.SalesRouteFragment" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_list"
android:name="com.xont.hemas.controller.sale.ItemListFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".sale.SalesRouteFragment"
tools:layout="@android:layout/list_content" />
<ListView
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFF"
android:choiceMode="singleChoice"/>
</android.support.v4.widget.DrawerLayout>
这是 salesRouteFragment.java
public class SalesRouteFragment extends SherlockFragmentActivity implements ItemListFragment.Callbacks,TabListener{
private boolean mTwoPane;
View rootView ;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.sales, menu);
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
rootView = LayoutInflater.from(SalesRouteFragment.this).inflate(R.layout.fragment_item_detail, null);
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
ActionBar.Tab tabA = actionBar.newTab().setText("SALES");
ActionBar.Tab tabB = actionBar.newTab().setText("INQUIRY");
ActionBar.Tab tabC = actionBar.newTab().setText("ADMIN");
tabA.setTabListener(this);
tabB.setTabListener(this);
tabC.setTabListener(this);
actionBar.addTab(tabA);
actionBar.addTab(tabB);
actionBar.addTab(tabC);
if (findViewById(R.id.item_detail_container) != null) {
mTwoPane = true;
((ItemListFragment) getSupportFragmentManager().findFragmentById(
R.id.item_list)).setActivateOnItemClick(true);
Bundle arguments = new Bundle();
arguments.putString(ItemDetailFragment.ARG_ITEM_ID, "KAN2R03");
arguments.putString("Code", "KAN2R03");
ItemDetailFragment fragment = new ItemDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
.replace(R.id.item_detail_container, fragment).commit();
}
}
这是我的 activity_item_list.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/invRetName"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:text="Visited Route : KAN2R03"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/invlasttxtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Visited Retailer Count : "
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="@+id/invlastInDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:orientation="horizontal"
android:showDividers="middle"
tools:context=".sale.ItemListActivity" >
<fragment
android:id="@+id/item_list"
android:name="com.xont.hemas.controller.sale.ItemListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
tools:layout="@android:layout/list_content" />
<FrameLayout
android:id="@+id/item_detail_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" />
</LinearLayout>
</LinearLayout>
请任何人帮助我....
提前致谢。