For now, we've seen that there are two ways to adapt to changes in the direction of the screen. Now, let's look at the following changes in the activity State as the screen direction changes.
1. Create a project: Orientations.
2. Main.xml documents.
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:layout_width=" fill_parent "
android:layout_height=" fill_parent "
android:o" rientation= "Vertical" >
<!--Note that this edittext uses the Android:id attribute--> <edittext android:id=
"@+id/ TxtField1 "
android:layout_width=" fill_parent "
android:layout_height=" wrap_content "/>
<!--attention , this edittext does not use the Android:id attribute-->
<edittext
android:layout_width= "Fill_parent"
android: layout_height= "Wrap_content"/>
</LinearLayout>
3, Orentationsactivity.java.
The public class Orientationsactivity extends activity {/** called the "when" is the "
@Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
LOG.D ("Stateinfo", "onCreate");
@Override public void OnStart () {log.d ("Stateinfo", "OnStart");
Super.onstart ();
@Override public void Onresume () {log.d ("Stateinfo", "Onresume");
Super.onresume ();
@Override public void OnPause () {log.d ("Stateinfo", "OnPause");
Super.onpause ();
@Override public void OnStop () {log.d ("Stateinfo", "onStop");
Super.onstop (); } @OverriDe public void OnDestroy () {log.d ("Stateinfo", "OnDestroy");
Super.ondestroy ();
@Override public void Onrestart () {log.d ("Stateinfo", "Onrestart");
Super.onrestart (); }
}