Reputation: 953
I am having a requirement where there are several buttons in a activity, and clicking on one will change the background. The activity refreshes on orientation change. Then i included, android:configChanges="keyboardHidden|screenSize"
which solves the problem, but i have separate screens for portrait and landscape modes, this saves the state and do not pick the layout for landscape when the orientation is changes. Please guide how i can change the orientation but still prevent the activity refresh and thus saving the clicked button and background color.
Upvotes: 1
Views: 4302
Reputation: 321
used this
android:configChanges="keyboardHidden|orientation|screenSize"
Upvotes: 3
Reputation:
dont use android:configChanges="keyboardHidden|screenSize"
and use onSaveInstanceState() for return color or resource id of background and then check it in oncreate() for set background
this example help you How to use onSavedInstanceState example please
Upvotes: 4