Question

I am using Fragments in my app project. All the fragments are added to back stack:

...
fragmentTransaction.addToBackStack(null);
...

Later on, what is the correct way to get all fragments from back stack in order ?

Était-ce utile?

La solution

Using the getBackStackEntryCount() you can iterate through the back stack and use the getBackStackEntryAt() method to get each Fragment.

EDIT: Based on some discussions in the comments, it is advised that you manually store a list of the Fragments you have added to your backstack, and persist these into your SharedPreferences. You can then read this list back when the application starts, and reload these fragments.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top