I have extended a DialogFragment. It just has an EditText and Accept and Cancel buttons.
Inside it, a text is entered to an EditText; then, upon clicking Accept, the text is checked using try/catch.
Inside the try, if everything goes fine, I dismiss the dialog; if the flow enters the catch, the idea is to retain the dialog and not dismiss it, to give the user the chance to correct the text.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
...
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
onAcceptDialog();
}
})
...
}
...
private void onAcceptDialog() {
try {
...
this.dismiss();
} catch (Exception e) {
...
//Dialog is still being dismissed here although it shouldn't
}
}
However, the dialog is still being dismissed although I am not calling this.dismiss() inside the catch.
Is there any way to cancel the dismissal once inside onAcceptDialog()?