Original URL: http://www.cnblogs.com/bluestorm/p/3665890.html
No screen rotation changes with phone
Sometimes we want to keep the interface of a program in one direction and not rotate with the phone:
Add the android:screenorientation= "Landscape" attribute to each activity configuration in the androidmanifest.xml that requires no steering.
Landscape = Landscape
Portrait = Portrait
Avoid restarting activity when you turn the screen
The activity is restarted every time the screen orientation is switched on Android, so you should save the current active state before the activity is destroyed and load the configuration when the activity is re-create, so that the in-progress game will not restart automatically!
To avoid restarting the activity when you turn the screen, you can redefine the direction in the Androidmanifest.xml file by adding android:configchanges= to each activity keyboardhidden| Orientation " property).
Override the onconfigurationchanged (Configuration newconfig) method in the activity where you want to control the display direction of the screen so that the activity does not restart when you turn the screen.
if (newconfig.orientation==configuration.orientation_landscape) { //transverse Setcontentview (r.layout.file_list _landscape);} else { //Vertical Setcontentview (r.layout.file_list);}
<activity android:name= "com.myapp.MyActivity" android:label= "@string/app_name" android: screenorientation= "Landscape" android:configchanges= "orientation" > <intent-filter> <action android:name= "Android.intent.action.VIEW"/> <category android:name= " Android.intent.category.DEFAULT "/> </intent-filter></activity>
android:screenorientation= "Landscape"
Android:configchanges= "Keyboardhidden|orientation"
@Overridepublic void onconfigurationchanged (Configuration newconfig) { super.onconfigurationchanged (newconfig) ; if (newconfig.orientation==configuration.orientation_landscape) { //transverse Setcontentview (r.layout.file_list _landscape); } else { //Vertical Setcontentview (r.layout.file_list); }}
In the simulator you can do screen rotation by CTL+F11 simulation.
Reference:
How to disable screens auto-rotation on Android
http://digitaldumptruck.jotabout.com/?p=897
How to disable screen rotation and restart activity in Android programs
Http://www.androidcn.com/news/20110302/00001299.html
"Go" How to disable screen rotation and restart activity in Android programs