tags:

views:

215

answers:

2

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

+1  A: 

One 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.

kgiannakakis
Thx for your reply. Is it possible do this without creating Custom dialog. using default positive and negative button to achieve this
I am afraid I don't know if it is possible or not.
kgiannakakis
It's not possible with the default dialog. You have to create a custom dialog.
YaW
A: 

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.

moonlightcheese