I have several snippets attached to the Android action bar as tabs. I can switch between them without any problems. However, if one of the fragments has a TextView (for example), and I change the text of this TextView , the new text is not saved if I switch to another tab and vice versa.
I tried to override onSaveInstanceState() , but it doesn't seem to be called when I switch tabs, since savedInstanceState is null every time onActivityCreated() is onActivityCreated() (i.e. every time this tab opens again).
I was looking for a change onPause() that calls onSaveInstanceState() , but onPause() does not have access to the status package, so I donβt see how to do it.
What is the best way to keep state on a tab when switching between tabs?
source share