if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
setContentView(R.layout.login);
}
else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
setContentView(R.layout.login);
}
I have 2 login.xml (one in layout folder, the other one is in layout-land folder). When first time I run the program it working fine (for example in PORTRAIT mode) and when I rotate the device it doesn’t call LANDSCAPE mode. it just rotate same login.xml.
Is there any solution for this?
Keep one login.xml in res/layout and another one in res/layout-land and remove the if else condition just put :
when the orientation of the device changes, Android will automatically load the appropriate XML file..
It works in my case …