0

I have 4 fragments: A, B, C and X.

A, B and C are found on the bottom navigation bar, so every time I click on item A, I get the A fragment on the screen, click on B, I get B.

enter image description here

enter image description here

enter image description here

When I click on C, I get the C fragment, which has a button, that takes me to X fragment. Now my problem is, that if I click on the Navigate to X button, after that when I navigate to anywhere from there and then back again on C, I get X.

enter image description here

But everytime I click on the item C, I want to get back to fragment C, no matter if I got to the X fragment before that. How can I implement this?

1 Answers1

0

I found the answer, I needed to pop the X fragment off the stack, with adding this to the action tag navigating to it:

app:popUpTo='nav_graph_id'

and

app:popUpToInclusive="true"