android學習日記之activity
阿新 • • 發佈:2019-01-09
package com.example.activity_1; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; public class OneActivity extends Activity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { Log.d("yuanbin", "----onCreate----"); super.onCreate(savedInstanceState); setContentView(R.layout.one_layout); } @Override protected void onStart() { Log.d("yuanbin", "----onStart----"); super.onStart(); } @Override protected void onResume() { Log.d("yuanbin", "----onResume----"); super.onResume(); } @Override protected void onPause() { Log.d("yuanbin", "----onPause----"); super.onPause(); } @Override protected void onStop() { Log.d("yuanbin", "----onStop----"); super.onStop(); } @Override protected void onDestroy() { Log.d("yuanbin", "----onDestroy----"); super.onDestroy(); } @Override protected void onRestart() { Log.d("yuanbin", "----onRestart----"); super.onRestart(); } public void buttonClick(View v) { switch (v.getId()) { case R.id.one_btn: { break; } case R.id.two_btn: { startActivity(new Intent(this, TwoActivity.class)); break; } case R.id.three_btn: { break; } default: break; } } } package com.example.activity_1; import android.app.Activity; import android.os.Bundle; public class TwoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.two_layout); } } <?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>