简体   繁体   中英

Go back to previous fragment but not previous activity

I have an Activity (A), that launch an other (B), in this activity (B) I have some fragments. When I press back on my activity B it's going correctly to the previous fragments, but when I click on back on the last fragment in the stack, it returns to the previous activity.

How can I do to not returning to the previous activity at the end ? (And also quit the app instead)

Have you tried using your FragmentTransaction 's addToBackStack(String name) method? As in:

fragmentTransaction.addToBackStack("NewFragment") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM