In my Activity I have two Gallery items one ExpandableListView and for the children of the ExpandableListView I am having a GridView. Program runs perfectly. What I need is to handle orientation change. I know, when orientation change, activity will call onDestroy and after that onCreate. Because of that my ExpandableListView will collapsed even though the user has expanded before he has done an orientation change.
I found a great concept for handling rotation changes in StackOverflow. This is the link. I have tried to implement that way but I have failed.
What I need is to take the same interface that user has used before the orientation change even after the orientation change happen. Please guide me.
Update with the Manifest content
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".activities.HomeActivity"
android:configChanges="keyboardHidden|orientation|screenLayout" >
<intent-filter>
<action android:name="android.intent.action.MAIN" ></action>
<category android:name="android.intent.category.LAUNCHER" ></category>
</intent-filter>
</activity>
<activity
android:name=".activities.WebViewActivity"
android:configChanges="keyboardHidden|orientation|screenLayout" >
</activity>
</application>
Handling rotation could be trivial and depends on what you have to react to when the screen rotates. If you have nothing in particular to do, you can always tell Android itself to manage the rotation, and avoid restarting your
activity. This could be achieved by declaring in theAndroidManifest.xmlandroid:configChanges="orientation". If you do so, Android will callonConfigurationChanged, that you can alwaysoverride. If you want your activity to restart when the screen rotates, you have to save the current state. That is, in your case, it could be the currentgroupsandchildrencurrently collapsed and re collapse. You can useonSavedInstanceState()/onRestoreInstanceState()to save and restore the states you need.Edit: if you are targeting API level 13, you have to add the
screenSizeoption to theandroid:configChangesin conjunction with theorientationoption as stated in the documentation: