FirstActivity.java package archie.android.life; 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; import android.widget.Button; public class FirstActivity extends Activity { private static final String TAG="activity"; private Button myButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.v(TAG, "onCreate"); myButton=(Button) findViewById(R.id.myButton); myButton.setText(R.string.startSec); myButton.setOnClickListener(new MyButtonListener()); } @Override protected void onDestroy() { super.onDestroy(); Log.v(TAG, "onDestroy"); } @Override protected void onPause() { super.onPause(); Log.v(TAG, "onPause"); } @Override protected void onRestart() { super.onRestart(); Log.v(TAG, "onRestart"); } @Override protected void onResume() { super.onResume(); Log.v(TAG, "onResume"); } @Override protected void onStart() { super.onStart(); Log.v(TAG, "onStart"); } @Override protected void onStop() { super.onStop(); Log.v(TAG, "onStop"); } class MyButtonListener implements OnClickListener{ @Override public void onClick(View v) { Intent intent=new Intent(); intent.setClass(FirstActivity.this, SecondActivity.class); FirstActivity.this.startActivity(intent); } } } main.xml <?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:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/myButton" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>