public class LifeCycleT extends Activity
implements View.OnClickListener {
private Button b1, b2, b3;
private Intent i;
private final static String TAG = "LifeCycleT";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG, "onCreate()");
i = new Intent(this, SubActivity.class);
b1 = (Button)findViewById(R.id.Button01);
b2 = (Button)findViewById(R.id.Button02);
b3 = (Button)findViewById(R.id.Button03);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
b3.setOnClickListener(this);
}
@Override
public void onStart(){
super.onStart();
Log.i(TAG, "onStart()");
}
@Override
public void onResume(){
super.onResume();
Log.i(TAG, "onResume()");
}
@Override
public void onPause(){
super.onPause();
Log.i(TAG, "onPause()");
}
@Override
public void onStop(){
super.onStop();
Log.i(TAG, "onStop()");
}
@Override
public void onRestart(){
super.onRestart();
Log.i(TAG, "onRestart()");
}@Override
public void onDestroy(){
super.onDestroy();
Log.i(TAG, "onDestroy()");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.Button01: dialOpen(); break;
case R.id.Button02: goSub(); break;
case R.id.Button03: finish(); break;
}
}
void dialOpen(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("캠페인");
builder.setMessage("아침밥은 먹고 다닙시다.");
builder.setNeutralButton("확인", null);
builder.show();
}
void goSub(){
startActivity(i);
}
}
public class SubActivity extends Activity
implements View.OnClickListener {
private Button b1, b2;
private Intent i;
private final static String TAG = "SubActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sub);
Log.i(TAG, "onCreate()");
i = new Intent(this, LifeCycleT.class);
b1 = (Button)findViewById(R.id.Button04);
b2 = (Button)findViewById(R.id.Button05);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
@Override
public void onStart(){
super.onStart();
Log.i(TAG, "onStart()");
}
@Override
public void onResume(){
super.onResume();
Log.i(TAG, "onResume()");
}
@Override
public void onPause(){
super.onPause();
Log.i(TAG, "onPause()");
}
@Override
public void onStop(){
super.onStop();
Log.i(TAG, "onStop()");
}
@Override
public void onRestart(){
super.onRestart();
Log.i(TAG, "onRestart()");
}@Override
public void onDestroy(){
super.onDestroy();
Log.i(TAG, "onDestroy()");
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.Button04: goMain(); break;
case R.id.Button05: finish(); break;
}
}
void goMain(){
startActivity(i);
}
} '스마트폰 > 안드로이드' 카테고리의 다른 글
Notification 공부. (0) | 2011.05.13 |
---|---|
명시적 intent 공부. (0) | 2011.05.13 |
묵시적 intent 공부. (0) | 2011.05.13 |
이미지뷰 두번째 공부. (0) | 2011.05.13 |
이미지뷰(ImageView) 공부. (0) | 2011.05.13 |