-1

I am using two different layouts for landscape and portrait mode. In landscape mode, I used scroll view.

I searched and found this solution

         android:configChanges="orientation|screenSize|keyboardHidden"  

But using this my scroll view is not working. How to retain data if the data is in spinners.

Shwetabh Singh
  • 197
  • 5
  • 15

2 Answers2

1

The official documentation explains both onSaveInstanceState() and retained Fragments via setRetainInstance(boolean).

For smaller data overriding onSaveInstanceState() in the activity is easier. You read your data from the Bundle in onCreate(Bundle).

http://developer.android.com/guide/topics/resources/runtime-changes.html

DSchmidt
  • 1,095
  • 9
  • 14
0

When orientation is changed, android destroys current activity and create a new one of the same class. And that new activity have its own lifecycle. To save any data - you should override method onSavedInstanceState and write parameters to bundle that u get from this method. To restore any parameters - you can get them from bundle which get when new Activity starts, for example in methods onCreate(Bundle)