tags:

views:

89

answers:

3

I am using two xml layout file layoutPotrait.xml and layoutLandscape.xml.When device/emulator is in portrait mode i want to set the content view with layoutPortrait.xml file and when I will change the emulator to landscape mode I want to set content view with layoutLandscape.xml file. How can I achieve this?

A: 

Press Ctrl-F11 or Ctrl-F12 on your keyboard. See Offical manual for more commands and hotkeys.

Alexander Kosenkov
Please read the question before answering it.
Janusz
Really thanks, but i want to set the content view with different layout file when i press Ctrl-F12.how can i do this in source code??
android_novice
I linked an article showing an example in my answer above, look for the code with onConfigurationChange.
molnarm
+1  A: 

To use different layouts for different orientations, place them in the appropriate folders: see Dev Guide on alternative resources (Screen Orientation section). For more info about changing the layout depending on orientation changes, see this article.

molnarm
+3  A: 

You don't need to know if the device changed. Just provide to layout files for all layouts you want to use in both ways.

If your Android device is in landscape mode and you are loading a layout the android system will look if this layout file exists in the /res/layout-land folder. If it does not exist in this folder it will load the layout from the normal /res/layout folder.

Just name the files the same and put the file that was called layoutPortrait.xml in your /res/layout folder and the layoutLandscape.xml in a /res/layout/land folder. If the folder does not exist create it.

Janusz
Thanks . Its working.
android_novice