我收到以下错误:
02-13 12:37:05.015: E/AndroidRuntime(8766): FATAL EXCEPTION: main
02-13 12:37:05.015: E/AndroidRuntime(8766): android.view.InflateException: Binary XML file line #9: Error inflating class fragment
02-13 12:37:05.015: E/AndroidRuntime(8766): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
...
02-13 12:37:05.015: E/AndroidRuntime(8766): Caused by: java.lang.IllegalArgumentException: Binary XML file line #9: Duplicate id 0x7f05005f, tag null, or parent id 0x0 with another fragment for com.handmark.pulltorefresh.extras.listfragment.PullToRefreshListFragment
02-13 12:37:05.015: E/AndroidRuntime(8766): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
02-13 12:37:05.015: E/AndroidRuntime(8766): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
02-13 12:37:05.015: E/AndroidRuntime(8766): ... 27 more
我正在创建一个带有 actionbar sherlock 的 android 应用程序,在选项卡之间进行水平滑动。对于每个选项卡,我都加载了一个片段,其中一个有问题。在这个片段中,我有一个嵌套片段,这对于下拉刷新列表至关重要。因此,我有以下布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_people_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/frag_ptr_list"
android:name="com.handmark.pulltorefresh.extras.listfragment.PullToRefreshListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollEnabled="true"
android:drawSelectorOnTop="false"
android:divider="@android:color/transparent"
android:layout_margin="10dp" />
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/footer_loading_data" />
</LinearLayout>
以及以下代码片段:
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
activity = getActivity();
mPullRefreshListFragment = (PullToRefreshListFragment)
activity.getSupportFragmentManager().findFragmentById(R.id.frag_ptr_list);
....
}
当我在选项卡之间滑动以及重新绘制片段时,问题就出现了。
只是让您知道,我正在使用支持库 v4。