I have a dialog with EditText for input. When I click the \"yes\" button on dialog, it will validate the input and then close the dialog. However, if the input
Inspired by Tom's answer, I believe the idea here is:
onClickListener during the creation of the dialog to nullonClickListener after the dialog is shown. You can override the onShowListener like Tom. Alternatively, you can
show()onClickListener as follows (slightly more readable I think). Code:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// ...
final AlertDialog dialog = builder.create();
dialog.show();
// now you can override the default onClickListener
Button b = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i(TAG, "ok button is clicked");
handleClick(dialog);
}
});