Fragment in Tab Activity will lose all data during rotation?

I use the Sherlock ActionBar library, and I have a SherlockFragmentActivity program that implements ActionBar.TabListener (for my tabs), and I have 3 tabs ... each of which is a Sherlock font. When I spin, all activity is recreated, and I lose all the variables declared in my onCreate inside the Fragment. How can i fix this?

I decided that I should use snippets as tabs instead of actions ... is this wrong?

EDIT: I should mention that my current workaround is to have static lists in Tab Activity and have a piece of push stuff for these onPause lists (and get stuff back from them onResume). I REALLY don't like to do this, and I know that there must be a better way.

Also, regarding if (savedInstanceState == null), I tried this and it does not seem to work. I think this is because the activity in which my fragments are stored is recreated, and the tabs need to be recreated.

+5
source share
1 answer

Fragment setRetainInstance(), true. , onCreate().

: http://developer.android.com/reference/android/app/Fragment.html

+5

All Articles