I have an ActionBar with List Navigation mode.
The problem is after selecting items from the navigation spinner, when the screen orientation changes the navigation spinner selected index is reset to 0.
How can I preserve the selected index of the spinner during configuration changes ?
Thanks
You should override
onSaveInstanceStateand save selected navigation list position to bundle.Don’t forget to restore position in
onCreate.Look at example below:
Provider<? extends Fragment>[] fragmentProvidersis a list of factory method objects which creates new fragment.Replace
getSupportActionBar()togetActionBar()andgetSupportFragmentManager()togetFragmentManager()if you don’t use actionbarsherlock