0

I got the following error:

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

I'm creating an android app with an actionbar sherlock with an horizontal swipe between the tabs. For each tab I have loaded a fragment and I have a problem in one of these. In this fragment I have a nested fragment, which is essential for the pull-to-refresh list. Hence, I have the following layout:

<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>

And the following snippet of code:

public void onActivityCreated(Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);
    activity = getActivity();
    mPullRefreshListFragment = (PullToRefreshListFragment) 
    activity.getSupportFragmentManager().findFragmentById(R.id.frag_ptr_list);
    ....
}

The issue comes out when I'm swiping between the tabs, and when the fragment is redrawn.

Just to let you know, I'm using the Support Library v4.

1 Answer 1

1

fragments cannot hold other fragments.

but .....

With current versions of the Android Support package -- or native fragments on API Level 17 and higher -- you can nest fragments, by means of getChildFragmentManager(). Note that this means that you need to use the Android Support package version of fragments on API Levels 11-16, because even though there is a native version of fragments on those devices, that version does not have getChildFragmentManager().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.