In general, the android:configchanges= "keyboardhidden|orientation" configuration is not used in the Androidmanifest.xml file, which is of course useful.
If we configure this property, we will call the Onconfigurationchanged method in the OnCreate method without re-executing the OnCreate method when we switch between the screen and the other. Of course, if you do not configure this property, you will recall the OnCreate method, the following is the test
Androidmanifest.xml file
<?xml version= "1.0" encoding= "Utf-8"?>
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.test"
Android:versioncode= "1"
Android:versionname= "1.0" >
<USES-SDK android:minsdkversion= "8"/>
<application android:icon= "@drawable/icon" android:label= "@string/app_name" >
<activity android:name= ". Testactivity "
Android:label= "@string/app_name"
android:configchanges= "Keyboardhidden|orientation" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Main.xml file
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
>
<textview
Android:id= "@+id/tv"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "screen switching test"
/>
<edittext
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:id= "@+id/et"
/>
</LinearLayout>
Testactivity.java file
Package com.test;
Import android.app.Activity;
Import android.content.res.Configuration;
Import Android.os.Bundle;
Import Android.widget.EditText;
Import Android.widget.TextView;
public class Testactivity extends Activity {
EditText et;
TextView TV;
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
ET = (EditText) Findviewbyid (r.id.et);
TV = (TextView) Findviewbyid (r.id.tv);
System.out.println ("I am the OnCreate method");
}
@Override
public void onconfigurationchanged (Configuration newconfig) {
Super.onconfigurationchanged (Newconfig);
if (newconfig.orientation = = Configuration.orientation_landscape) {
Tv.settext ("horizontal screen");
}else{
Tv.settext ("vertical screen");
}
}
}
About the properties of Android:configchanges (GO)