Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested Fragments using support library v4 revision 11

The last revision of the support library from this morning (Android Support Package v4 revision 11) is supposed to support nested fragments.

In my project I have a fragment that contains a ViewPager and this ViewPager contains several fragments.

I'm calling getSupportFragmentManager() instead of getFragmentManager to use the FragmentManager of the support library.

The problem is I'm still experiencing crashes like :

java.lang.IllegalStateException: Recursive entry to executePendingTransactions
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:523)
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:495)
    at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1221)
    at android.view.View.dispatchRestoreInstanceState(View.java:11910)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2584)
    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2590)
    at android.view.View.restoreHierarchyState(View.java:11888)
    at android.support.v4.app.Fragment.restoreViewState(Fragment.java:417)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:933)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)

Is there anything I'm doing wrong ? Or the support doesn't support nested fragments for real ?

My transactions are as simple as this:

getSupportFragmentManager().beginTransaction()
                    .replace(R.id.content, new MyFragment()).commit();
like image 440
Timothée Jeannin Avatar asked Nov 14 '12 10:11

Timothée Jeannin


1 Answers

Try using getChildFragmentManager() instead of getSupportFragmentManager(). this should help

like image 172
user1837704 Avatar answered Nov 15 '22 19:11

user1837704