I have in my app two layouts - there's always only one of them visible - let's call them basic and alternative. When the app starts, the basic layout is set to visible, alternative - to gone. Pushing a button can change that to the opposite - basic gone, alternative visible. Pushing a button in the alternative layout - changes it back.
The main problem is - when I'm in the alternative layout view and I rotate the screen, it goes back to the basic one. The same thing happens after sliding out the keyboard on my Milestone.
Is there any simple way to prevent that from happening?
I tried adding to the manifest
android:configChanges="keyboardHidden|orientation"
and then in the main activity the onConfigurationChanged method that does actually nothing, but I guess I don't understand the idea properly.
Thanks for help in advance.
When the orientation is changed, the activity is recreated. So, layouts are reinflated, etc. You should have a boolean that is toggled when the layouts are changed. Then check the boolean in your onCreate method and display the correct layout. This link may be helpful.