Reputation: 5614
Application has a tabhost managed through TabActivity. It has option to add tabs at runtime.
Say 5 tabs are added in runtime and different activities are shown.
When I rotate the screen the activity undergoes the cycle o destroy and create. I want to maintain the tabs added by user in runtime to be available during this cycle.
Upvotes: 1
Views: 1012
Reputation: 368
The easiest way to do this is to change your Manifest to say that you will handle the orientation change yourself.
<activity
android:name=".MyActivity"
android:configChanges="orientation" />
What this does is tell the system to not recreate the activity on orientation change. You can then override OnOrientationChanged to modify any configuration changes.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//put configuration changes here
}
You can also leave it out if you don't need any explicit changes.
For further reading: Android Runtime Changes
Upvotes: 1