Is there some way to do validation upon clicking ok. Im not dismissing it but it closes when I click Ok. I have written a custom AlertDialog that uses some edit texts. Probl
You can do this by overriding the onClickListener. The trick is to get the button after create and showing the dialog.
// Create you dialog here and show it
...
dialog.show();
Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View onClick) {
// Valid checking
...
if (valid) {
dialog.dismiss();
} else {
// Not valid
}
}
});