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 is wrong, I want to remain in the same dialog. Every time no matter what the input is, the dialog should be automatically closed when I click on the "no" button. How can I disable this? By the way, I have used PositiveButton and NegativeButton for the button on dialog.
Android – How to prevent a dialog from closing when a button is clicked
androidandroid-alertdialogandroid-dialogandroid-dialogfragmentdialog
Related Topic
- Android – How to stop EditText from gaining focus at Activity startup in Android
- Android – Is quitting an application frowned upon
- Android – How to display an alert dialog on Android
- Android – way prevent AlertDialog from closing with invalid inputs
- Javascript – How to create a dialog with “yes” and “no” options
- Android – Prevent back button from closing a dialog box
- Android – How to create a Custom Dialog box in android
- Android – Prevent DialogFragment from dismissing when button is clicked
Best Answer
EDIT: This only works on API 8+ as noted by some of the comments.
This is a late answer, but you can add an onShowListener to the AlertDialog where you can then override the onClickListener of the button.