سؤال

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 ?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top