Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android 4.0 Dialog gets canceled when touched outside of dialog window

Hi I am facing the problem on ICS like dialog is dismissed when we click outside dialog window, due to which I am getting problem like I don't get any confirmation from user.

Please help.

like image 381
nishi Avatar asked Mar 22 '12 19:03

nishi


People also ask

How do I stop dialog close on click outside Android?

Simply, alertDialog. setCancelable(false); prevent user from click outside of Dialog Box.

How do I keep my dialog from closing?

AlertDialog dialog = (AlertDialog) getDialog(); dialog. getButton(AlertDialog. BUTTON_POSITIVE). setEnabled(false);

How do you dismiss dialog with click on outside of dialog?

You can use dialog. setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog.


2 Answers

Check this method from the Android Developers site for dialog.

Try using the

dialog.setCanceledOnTouchOutside (boolean cancel)

Pass a boolean value to enable/disable dialog behaviour when touched outside of the dialog window.

Also go through these links:

How do I fire an event when click occurs outside a dialog

How to cancel an Dialog themed like Activity when touched outside the window?

I hope this answers your question.

like image 97
Harshawardhan Avatar answered Nov 30 '22 22:11

Harshawardhan


You may use

dialog.setCancelable(true/false); 

OR

dialog.setCanceledOnTouchOutside(true/false); 

For the latest vesrions of Android;

It will disable outSideTouching event.

like image 37
Amt87 Avatar answered Nov 30 '22 23:11

Amt87