Does Android 3 or more support levels of nested fragments?

I have a lot of problems when adding 3 levels of nested fragments programmatically. I currently have an Activity that loads Fragment A through its fragmenter, which then loads Fragment B through the child FragmentManager, which then loads C fragment from B childFragmentManager.

Fragments are initially loaded with a fine. But the problem is that fragments are destroyed and then recreated. You might think that when fragment B is destroyed, there will also be fragment C. But it seems that fragment C remains hanging.

As it is now, Fragment B is loaded through the ViewPager in fragment A. When I scroll a page from a page, I sometimes get the following error:

java.lang.IllegalStateException: Fragement no longer exists for key android:target_state: index 1

If I remove the C fragment from the equation, the error will disappear. It also doesn't crash if I load all the fragments into their parent instanceManager (instead of childFragmentManager)

+5
source share
1 answer

The answer is absolutely yes . You can have 3 levels. using it successfully in my application.

+2
source

All Articles