Material-dialogs: How to stop dialog from dismissing when clicked on positive button.

Created on 22 May 2016  路  6Comments  路  Source: afollestad/material-dialogs

I have overriden the onclick method in onPositive of the dialog and there i check whether anything is entered in the editText in the dialog box. If it is i want to dismiss the dialog if not then do not dismiss the dialog. I put if-else condition for checking if editText is empty but by default the dialog is dismissed after clicking on Positive button.

if(string!=null && !string.isEmpty()){
dialog.dismiss();
}
else{
Toast.makeText(context,"Enter something,LENGTH.SHORT);
}

Most helpful comment

Also, that StackOverflow post has nothing to do with this library.

If you read the README documentation, you'd see there's an autoDismiss property which is true by default. When disabled, the dialog will remain open. @sarthak1996 @peppe130

All 6 comments

See here

The .positiveText method of this dialog only takes one parameter (the title of the positive button). I can't pass null as done in the stackoverflow eg..

You can pass null if you cast to a String, null by itself is ambiguous cause the compiler doesn't know if you mean positiveText(int) or positiveText(String).

However, you should not do that anyways. Instead, don't use positiveText() at all. The default is null already.

Also, that StackOverflow post has nothing to do with this library.

If you read the README documentation, you'd see there's an autoDismiss property which is true by default. When disabled, the dialog will remain open. @sarthak1996 @peppe130

Thanks a lot....

See here

I have a question about the solution in this link. I extend AppCompatDialogFragment from my class, and I override the onCreateDialog method. So, I tried to solve my problem with this solution which is given in link. But I did not understand class structure like which class is extended, which function is overrided. Can you tell me which class is extended and which function is overrided?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arpanbag001 picture arpanbag001  路  4Comments

bahmandamia6982 picture bahmandamia6982  路  6Comments

bernaferrari picture bernaferrari  路  5Comments

jahirfiquitiva picture jahirfiquitiva  路  6Comments

palaima picture palaima  路  4Comments