Why don't work setText("")? EditText stores last input data and when i call the AlertDialog again, show stored data.
case IDD_SET_NAME:
builder=new AlertDialog.Builder(this);
builder.setTitle("Name Title");
EditText input = new EditText(this);
input.setText("");//This method not work
builder.setView(input);
builder.setPositiveButton("Create", onClickListener_DialogResetPin);
builder.setNeutralButton("Cancel", onClickListener_DialogResetPin);
// create and show dialog
dialog = builder.create();
dialog.show();
Button btnOK = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
btnOK.setOnClickListener(onClickListener_btnOK);
break;
Your Dialog
is not destroyed if you dismiss
it. So, if you show it again, it will not be recreated and input.setText("");
will not run. If you want the dialog
to be recreated, use removeDialog()
instead of dismissDialog()
You are in onCreateDialog. This is called the first time you show a dialog, only. If you have modifications to perform on your alert, you should do it in onPrepareDialog.
A little debugging and documentation reading would have helped you here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.