简体   繁体   中英

save state activity when switch to another activity

I have bottom navigation in my app. Each tab of bottom navigation is activity. For example I have 3 tabs in my bottom navigation and tab 1 is activity_one, tab 2 is activity_two, tab 3 is activity_three. Every activity include some fragment. when I switch between tabs I think activity that I selected, recreated again. I want to save state of my activity.that means when I selecet tab 1, and do some action in this tab (for example replace fragment) and switch to tab 2 and switch to tab 1, it shows last action that I've done before(fragment changed for example) what should I do? PLEASE help me

you should not implement this structure in multiple activities. change your structure and replace your activities with one activity as parent Activity and you should have a frame above your bottom navigation and replace fragments in your parent activity's frame, and then you can use same fragment instance for your tabs and save your fragments state.

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