简体   繁体   中英

Maintain Back Stack in Android Fragments

I have a list view in Android. During every click of list item, I have load a Single view name "Template Fragment" for every click dynamically. After click on Sub Views, I have loaded the same View "Template Fragment" again dynamically. Now I have multiple views creating from the same Fragment. Now my problem is to maintain back stack of all the views. How I can achive this.

Please help me for the same.

Thanks in advance. Any help is appreciated.

use the following code,

//add to back stack
transaction.addToBackStack(type.getClass().getName());

//Commit the transaction
transaction.commit();

String as parameter might help in identifying fragments

In case you don't need to identify this back stack later on, pass null for addToBackStack .

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