onCreateDialog onPrepareDialog

第一次调用showDialog时,先执行onCreateDialog再执行onPrepareDialog

之后再次调用时,则只执行onPrepareDialog


@Override
protected void onPrepareDialog(int id, Dialog dialog) {
Log.i(TAG, "onPrepareDialog:" + id);

switch (id) {
case DIALOG_TEST_ID:
((AlertDialog) dialog).setMessage("clickCount:" + clickCount);
clickCount++;
break;
default:
break;
}


super.onPrepareDialog(id, dialog);
}


@Override
protected Dialog onCreateDialog(int id) {
Log.i(TAG, "oncreateDialog:" + id);
switch (id) {
case DIALOG_TEST_ID:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("测试Dialog");
builder.setPositiveButton("OK", new OnClickListener() {


@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();


}
});
return builder.create();
}
return super.onCreateDialog(id);
}


你可能感兴趣的:(测试,dialog)