-5

There are a lot of fragment in the activity of my project. For example: Now I have used begintransaction to intent from A to B fragment or C to B fragment, and in B fragment i have any button, and I click into it, it will be returned parent fragment. Every one can help me a suggestion or advise.

  • Reason for downvote? Duplicate? Include link if so. – Talha Jan 23 '17 at 08:17
  • sorry, but it's not possible, I tried all suggestion, but it's not working. – Le Thanh Tan Jan 23 '17 at 09:14
  • Your question is not clear. Please clearly state your problem. If your English is not good enough, try providing some code or even pictures to explain your problem. That's probably the reason for the downvotes. – David Wasser Jan 23 '17 at 11:35

1 Answers1

2

just one line of code you need to write

getSupportFragmentManager().popBackStackImmediate();

you have to use

addToBackStack

so that you can popBack from fragment manager so like this.

getSupportFragmentManager().beginTransaction()
                           .replace(detailFragment, "detail")
                           // Add this transaction to the back stack
                           .addToBackStack()
                           .commit();
AJay
  • 1,233
  • 10
  • 19