By default, the Onconfigurationchanged event triggers when the screen changes from a vertical to a horizontal screen, which by default reloads the screen and displays the same screen as the horizontal screen, which can have 2 problems.
* Layout problems, in the vertical display of the layout to the horizontal screen due to the width and height of the changes all will affect the layout (unless you customize 2 sets of images and then add a judge in the horizontal screen how to show, in the vertical screen how to display), of course, the easiest way is in The androidmanifest.xml of the project is found in the activity you specify plus
o Only Vertical screen display (android:screenorientation= "Portrait")
o Only Horizontal screen display words (android:screenorientation= "Landscape")
* Screen Reload Problem: By default, the switch will reload the screen, lead to unnecessary waste of resources, and more seriously, the data maintained on the screen (especially the game) has been reset (of course, you can save the data to the database or to a text file before resetting), how to avoid Reload the screen when you switch,
o First of all, find the activity you specified in Androidmanifest.xml, plus android:configchanges= "Orientation|keyboardhidden."
O then overload the Onconfigurationchanged event in the logical processing of the activity (part of the code), referring to the specific code:
+ @Override
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
}
In the onconfigurationchanged, decide whether to display a horizontal or vertical screen and then Setcontentview
There's a way.
The Layout-port and Layout-land are established under the Res folder, and the layout files (with the same name) of the vertical and horizontal screens are automatically invoked.
The above can be simple to control the display of your app screen and in the same way that the display mode does not change the screen will not reload the screen, that is, optimize your app at the same time the user experience also improved accordingly.
Source: http://blog.csdn.net/muyu114/archive/2011/04/20/6334875.aspx