1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| package com.example.activitytest;
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 MainActivity extends Activity { private Button btn; private static final String TAG = "ActivityTest"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "MainActivity onCreate"); setContentView(R.layout.activity_main); btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this,SecondActivity.class); startActivity(intent); } }); } @Override protected void onPause() { Log.d(TAG, "MainActivity onPause "); super.onPause(); } @Override protected void onResume() { Log.d(TAG, "MainActivity onResume "); super.onResume(); } @Override protected void onStart() { super.onStart(); Log.d(TAG,"MainActivity onStart "); } @Override protected void onStop() { super.onStop(); Log.d(TAG, "MainActivity onStop "); } @Override protected void onDestroy() { super.onDestroy(); Log.d(TAG, "MainActivity onDestroy "); } @Override protected void onRestart() { super.onRestart(); Log.d(TAG, "MainActivity onRestart "); } }
|