I have a dialog with edittext for input. when i click yes button on dialog, it will validate the input and then close dialog. However, if the input is wrong, i want to remain in the same dialog. every time no matter what input it is, the dialog always automatically close when i click button. How can i disable this. By the way, i use PositiveButton and NegativeButton for the button on dialog
views:
215answers:
2One solution will be to create a Custom Dialog with the desired functionality.
This link will give you some information on how to extend the Dialog class in order to create your won dialog.
i think the answer is to use NeutralButton rather that PositiveButton. when you click the NeutralButton, it does not dismiss the dialog unless Dialog.dismiss() is called. this way you can call Dialog.dismiss() upon successful completion of the criteria.
SCRATCH THAT:
just tried it, and it didn't work. the best thing i can think of is to use an if statement that reopens the dialog if the criteria isn't met. you can call onCreateDialog (or whatever function you've used to create your dialog) and make a Dialog option from that, and use it's show() method. i just implemented this and it's ugly, but it worked.