Oreintation not change in android 2.3
I have created an application, Which required to support lan开发者_JAVA技巧dscape & portrait mode.
For that, I have set portrait layout in layout folder and landscape layout in layout-land folder. In android 2.3.1 simulator when i run application then first time open portrait mode i change orientation then landscape and change layout but when again change mode then simulator change in portrait mode but layout is not change it is used landscape layout. After all this i tried this method.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
or
android:configChanges="orientation|keyboardHidden"
in manifest file. but no effects. Pls help me. Thanks
There is a bug with that version of the emulator and it doesn't pick up rotation changes sometimes
edit: does for me anyway >_> and works fine on phones, and I THINK i've read this somewhere before
source: http://groups.google.com/group/android-developers/browse_thread/thread/141c1b1ba937e7a7
http://code.google.com/p/android/issues/detail?id=13193&q=emulator%20rotate&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars :)
http://www.southparksystems.com/devzilla/2010/3/3/switching-layouts-when-screen-orientation-changes-in-android.html
First you need to put two layouts in different folder like layout/test_layout.xml and layout-land/test_layout.xml
Then, You can create custom layout by extending RelativeLayout or LinearLayout which you used in test_layout.xml
Then, Inflate the test_layout.xml in custom layout class, so your problem of orienation change will be solve.
精彩评论