views:

12

answers:

1

I have a issue about spinner. I have many images in spinner when I select some image it shows the image and if I change the orientation like change to landscape its selected item list starts pointing the top one in the list. How shall I prevent to do that?

A: 

Step #1: Override onRetainNonConfigurationInstance() and, as part of whatever you return, include getSelectedItemPosition() from the Spinner.

Step #2: In onCreate(), call getLastNonConfigurationInstance(). If it is not null, that is the object you returned in Step #1 above. Use the value from it to call setSelectedPosition() on the Spinner to set the selection to whatever it was before.

CommonsWare