Android Screen Orientation Handling For Spinner
I have a activity in which there is a spinner. since for portrait and landscape mode i have different layout so I am changing layout in onConfigurationChanged method @Override
Solution 1:
try spinner's performClick() method
Solution 2:
To stop re-creation of your Spinner you can add this in your Manifest file
<activityandroid:name=".Activity_name"android:configChanges="orientation|keyboardHidden">
But by adding this your Layout will not be changed automatically when you rotate your device, so you have to manage that manually like this,
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
setContentView(R.layout.login_landscape);
}
else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.login);
}
}
For more information you can check my answer here
.
Solution 3:
Once the orientation changes, destroy method get called and your activity re-create once again. To avoid destroy method get called you need to add below codes in manifest file. But in this case only one layout can be used, if you want to repostion your contents you need to do it dynamically then.
android:configChanges="orientation|keyboardHidden"
Post a Comment for "Android Screen Orientation Handling For Spinner"