android - Fragment Back Button Navigation -
Suppose i have 3 pieces: a, b, c
- I Go to - & gt; B
- B -> C
- C -> B (without pressing the back button)
- B -> C (without pressing the back button)
- C -> B (without pressing the back button)
- B -> C (without pressing the back button)
Now by pressing the Back Button, Navigation C-> B-> A-> should be there.
In other words, B-> Regardless of the number of navigation between C and C-> B (without pressing the back button) back to the navigation order should be in C-> B - & gt; A
assuming that all allowed transit A & lt; - & gt; B & lt; - & gt; C, you can use C-> B using the
FragmentManager.popBackStack () method, and whenever you add the transition to return stacks while navigating the B-> C < / p>
How to make changes here:
Public Zero Infection FROMATOB () {getSupportFragmentManager () BeginTransaction () .replace (R.id.fragment_container, new fragmentB ()) .addToBackStack (null) .commit (); } Public Zero Infection FROMBToC () {getSupportFragmentManager (). BeginTransaction () .replace (R.id.fragment_container, new FragmentC ()). AddToBackStack (null) .commit (); } Public Zero TansitionFromCToB () {getSupportFragmentManager (). PopBackStack (); } Public Zero Infection FROMBToA () {getSupportFragmentManager (). PopBackStack (); }
So when C-> B infection is happening, then you are not actually doing a new infection, you actually just have B-> The C transitions are backwards.
Comments
Post a Comment