Rotating screen, my listview (ListActivity) disappears. android:configChanges flag makes no difference

StackOverflow https://stackoverflow.com/questions/23530204

Question

Rotating screen, my listview disappears. (API 19). I have a list adapter, db helper that I initialize in onCreate() in my ListActivity. Rotating screen, my listview disappears. Per https://stackoverflow.com/a/2902944/398348, I tried

 <activity
    android:name="com.mypkg.MyListActivity"
    android:label="@string/app_name" 
    android:configChanges="keyboardHidden|orientation" >

It made no difference.

Also I am trying to understand - if my variables (list adapter etc) are recreated in onCreate(), then won't this be run anyway when activity is destroyed and recreated? Why do I need to do it again in onSaveInstanceState?

Was it helpful?

Solution

For the first part of your question try changing the configChanges to

android:configChanges="orientation|screenSize"

This is because when you switch orientation, the screen size changes as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top