Android ListView in Activity getting Refreshed on Changing Orientation

For those targeting API 13 or higher, "screenSize" should also be used. If that is your case, add

android:configChanges="orientation|screenSize"

to your Android manifest.

More information here.


Android will stop and restart your activity unless you've told it you will handle orientation changes yourself. It does this so that you can specify different resources (such as layouts) that are orientation-specific (among other reasons).

You need to add android:configChanges="orientation" to your activity delcaration in your AndroidManifest.xml, and you need to override onConfigurationChanged(). I don't believe you need to do anything special inside onConfigurationChanged(), simply implementing it should do the trick.