如何解雇时pressing对话外的DialogFragment? [英] How to dismiss a DialogFragment when pressing outside the dialog?

查看:148
本文介绍了如何解雇时pressing对话外的DialogFragment?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 DialogFragment ,虽然我已经成功地将图像设置为关闭(即解雇),我有当pressed对话框很难找到方法来关闭该对话框,当用户点击它之外的任何地方,只是因为它的工作原理与普通的对话框。我以为会有某种

  dialogFragment.setCanceledOnTouchOutside(真正的);
 

电话,但我没有看到的文件中。

这可能与 DialogFragment 呢?还是我找错了地方?我试图拦截触摸事件中的父的活动,但除此之外没有得到任何触摸事件,它似乎没有我的权利。

解决方案

  DialogFragment.getDialog()setCanceledOnTouchOutside(真)。
 

如果工作

I am using a DialogFragment, and while I have successfully set an image to close (i.e. dismiss) the dialog when pressed, I am having a hard time finding the way to dismiss the dialog when the user clicks anywhere outside it, just as it works with normal dialogs. I thought there would be some sort of

dialogFragment.setCanceledOnTouchOutside(true);

call, but I don't see that in the documentation.

Is this possible with DialogFragment at all? Or am I looking in the wrong places? I tried intercepting touch events in the 'parent' activity but apart from not getting any touch event, it didn't seem right to me.

解决方案

DialogFragment.getDialog().setCanceledOnTouchOutside(true);

Should work

这篇关于如何解雇时pressing对话外的DialogFragment?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆