Reputation: 3084
I have a start activity, which has a navigation drawer and the rest of the space is occupied by fragments. The drawer has 3 menu items. So when a user selects menu item A from the drawer, fragment A shows; menu item B shows fragment B and so on. Fragment A can go to fragment A1, A2... and so on, and Fragment B can go to fragment B1, B2... and so on.
-> A -> A1 -> A2 -> A3
Start -> B -> B1 -> B2 -> B3
-> C -> C1 -> C2 -> C3
(You can think of A, B, C... as separate "wizard" dialogs).
My question is, how can I maintain which fragment to show when users switch A/B/C on the navigation drawer on the start activity? For example, user selects drawer menu item A and goes to A1, A2 then A3. She then selects B and goes B1 then B2. When she selects drawer menu item A again, how can the start activity go back to A3? And when she presses back button on A3, it will go back to B2.
What I am looking for is using the simplest way (e.g. out of box Android framework) without having to write too much code.
Upvotes: 0
Views: 1892
Reputation: 812
This SO question can help you maintain backstack of the fragment. Apart from this when user selects itemA from navigation drawer, you can change the drawer menu if you want to let user select itemA1, itemA2. . .
On any item selection from drawer menu, push it in backstack. Then on back press, you should pop these fragments from backstack.
Upvotes: 1