Life Cycle Pictures:
650) this.width=650; "src=" http://img.blog.csdn.net/20141127100106218 "/>
To test the main page layout:
: Layout/activity_main.xml
<relativelayout xmlns:android= "http://schemas.android.com/ Apk/res/android "
xmlns:tools=" Http://schemas.android.com/tools "
Android:layout_ Width= "Match_parent"
android:layout_height= "match_parent"
android:paddingbottom= "@dimen/activity_vertical_margin"
android:paddingleft= "@dimen/activity_horizontal_margin"
android:paddingright= "@dimen/activity_horizontal_margin"
android:paddingtop= "@dimen /activity_vertical_margin "
tools:context=". Mainactivity
<button
android:id= "@+id/button"
android:layout_width= "match_parent"
android:layout_height= " Wrap_content "
android:text=" Start secondactivity "/>
</relativelayout
To test the main page Java code:
Package com.sxt.day04_03;
Import android.app.Activity;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.util.Log;
Import Android.view.View;
Import Android.view.View.OnClickListener;
public class Mainactivity extends Activity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
LOG.I ("main", "OnCreate ()");
Setlistener ();
}
private void Setlistener () {
Findviewbyid (R.id.button). Setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View v) {
Intent intent=new Intent (Mainactivity.this, Secondactivity.class);
StartActivity (Intent);
}
});
}
@Override
protected void OnStart () {
Super.onstart ();
LOG.I ("main", "OnStart ()");
}
@Override
protected void Onresume () {
Super.onresume ();
LOG.I ("main", "Onresume ()");
}
@Override
protected void OnPause () {
Super.onpause ();
LOG.I ("main", "OnPause ()");
}
@Override
protected void OnStop () {
Super.onstop ();
LOG.I ("main", "OnStop ()");
}
@Override
protected void OnDestroy () {
Super.ondestroy ();
LOG.I ("main", "OnDestroy ()");
}
@Override
protected void Onrestart () {
Super.onrestart ();
LOG.I ("main", "Onrestatr ()");
}
}
Second second page layout:
: Layout/activity_second.xml
<relativelayout xmlns:android= "http://schemas.android.com/apk /res/android "
xmlns:tools=" Http://schemas.android.com/tools "
Android:layout_ Width= "Match_parent"
android:layout_height= "match_parent"
android:paddingbottom= "@dimen/activity_vertical_margin"
android:paddingleft= "@dimen/activity_horizontal_margin"
android:paddingright= "@dimen/activity_horizontal_margin"
android:paddingtop= "@dimen /activity_vertical_margin "
tools:context=". Secondactivity
<textview
android:layout_width= "Wrap_ Content "
android:layout_height=" wrap_content "
Android: text= "@string/hello_world"/>
</relativelayout>
Second secondary page Java code:
Package com.sxt.day04_03;
Import android.app.Activity;
Import Android.os.Bundle;
public class Secondactivity extends Activity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_second);
}
}
Effect:
650) this.width=650; "src=" http://img.blog.csdn.net/20141127100810506 "/>
650) this.width=650; "src=" http://img.blog.csdn.net/20141127100832596 "/>
This article from "Follow the heart of the other side" blog, declined reprint!
The life cycle of Android activities