¿¹Á¦µéÀ» º¸¸é¼ °øºÎÁß¿¡ Àִµ¥.. ±Ã±ÝÇÑ °ÍÀÌ ÀÕ¾î¼ ±ÛÀ» ¿Ã¸³´Ï´Ù.
´ÙÀ½°ú °°Àº ¼Ò½º°¡ ÀÖ°í
package org.kadicon.android.dialog;
import org.kadicon.android.dialog.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MyDialog extends Activity {
private static final int DIALOG_MESSAGE = 1; // final º¯¼ö ¼±¾ð.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button twoButtonsTitle = (Button) findViewById(R.id.show_dialog);
twoButtonsTitle.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new AlertDialog.Builder(MyDialog.this).setTitle(
"My Dialog Title").setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked OK so do some stuff */
}
}).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked Cancel so do some stuff */
}
}).show();
}
});
}
@Override
protected void onPause() {
super.onPause();
Log.i("Dialog", "onPause()");
Toast toast = Toast.makeText(this, "onPause", Toast.LENGTH_LONG);
toast.show();
}
@Override
protected void onResume() {
super.onResume();
Log.i("Dialog", "onResume()");
Toast toast = Toast.makeText(this, "onResume", Toast.LENGTH_LONG);
toast.show();
}
//??????
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_MESSAGE:
return new AlertDialog.Builder(MyDialog.this).setTitle(
"Saved?").setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked OK so do some stuff */
}
}).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked Cancel so do some stuff */
}
}).create();
}
return null;
}
}
Á¦°¡ ±Ã±ÝÇÑ°ÍÀº À§¿¡¼ onCreateDialog ¿¡´ëÇÑ ¸í·ÉÀÌ ´Ù ³¡³ °ÍÀÌ ¾Æ´ÑÁö
¿Ö ¹Ø¿¡ ±»ÀÌ
//??????
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_MESSAGE:
return new AlertDialog.Builder(MyDialog.this).setTitle(
"Saved?").setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked OK so do some stuff */
}
}).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
/* User clicked Cancel so do some stuff */
}
}).create();
}
return null;
}
}
ÀÌ·¯ÇÑ ¹®ÀåÀÌ µé¾î°¡´Â °É±î¿ä?
¶ÇÇÑ @override ´Â ¾î¶²Àǹ̸¦ °®°í ÀÕ³ª¿ä
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)