I'd like to close a dialog window in my android app by simply touching the screen.. is this possible? If so, how?
I've looked into setting some "onClickEven" on the dialog, but it doesnt exist.
How would this be possible?
You can use dialog. setCanceledOnTouchOutside(true); which will close the dialog if you touch outside of the dialog. Window window = this.
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.
Dialog dialog = new Dialog(context)
{
public boolean dispatchTouchEvent(MotionEvent event)
{
dialog.dismiss();
return false;
}
};
And you are done!
You can use dialog.setCanceledOnTouchOutside(true);
which will close the dialog if you touch u=outside the dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With