AndroidDev AndroidDev - 1 year ago 114
Android Question

How to prevent dialog to open twice

I had button in my app, on doubleClick of my button i open a dialog.Sometimes what happen when i doubleClick the button in a fast way then the dialog open twice, as a result of which the user has to cancel the dialog twice.

So can anyone suggest me how can i prevent this dialog to open twice on doubleClick of my button.

Answer Source

May be this will help you:

Take a count variable i.e., count=0;. In button click validate condition such that if(count==0) show dialog and make count to 1. (with this dialog will not open second time) while dismissing dialog make count to 0 again.

I think this will work

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download