Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Honeycomb - Action Bar tab fragments save/restore state

Tags:

android

In the docs it says to ensure you save a fragment's state when using tabs with the action bar so that when you switch tabs the fragment will look as it did before. How is this done? Using the sample for handling tabs, onSavedInstanceState is not called when the tab is switched so where would I save the state? Do I do it at the activity level? I only want the state to be transient.

Thanks

like image 675
Nic Avatar asked Nov 14 '22 22:11

Nic


1 Answers

Fragment.onSaveInstanceState() is the proper place. That will be called when the state needs to be saved. If it isn't called, it doesn't need to be saved yet.

like image 181
hackbod Avatar answered Jan 06 '23 18:01

hackbod