hosein2rd
hosein2rd

Reputation: 45

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

Upvotes: 0

Views: 86

Answers (1)

Reza.Abedini
Reza.Abedini

Reputation: 2257

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.

Upvotes: 1

Related Questions