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
If your dialog contains any view try to get the touch events in that view and dismiss your dialog when user touch on that view. For example if your dialog has any Image then your code should be like this.
Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.mylayout);
//create a layout with imageview
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();