I need help!
I'm developing an android app and I ran into a problem.
I have an AlertDialog
which contains two buttons(positive and negative). When a button is clicked certain code runs, then the dialog is closed.
dialog.setNegativeButton("button name", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// some code
}
});
But that's not what I want. When the users clicks the negative button I want some code to run and then the dialog SHOULDN'T be closed.
dialog.setNegativeButton("button name", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// some code
// code to prevent the dialog from being closed ?
}
});
Is there anything I can do to prevent the dialog from being closed when the positive or negative button is clicked ?
I tried using this code:
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);
But it doesn't work because now the user can't click the button.
BTW I'm developing for minimum sdk version of 16.
Thanks for helping!