在对话外的Andr​​oid click事件 [英] Android click event outside a dialog

查看:94
本文介绍了在对话外的Andr​​oid click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道怎么解决,我有一个问题。 我有一个对话框会弹出一个活动。该对话框不覆盖整个屏幕,所以从活动的按钮仍然显示。我可以很容易地关闭对话框时有对话框的边界之外的接触 dialog.setCanceledOnTouchOutside(真); 但是我想要做的是触发一个事件,如果某次点击对话框的边界之外(例如,如果有人触碰的主要活动的一个按钮,它应该关闭对话框,并触发该事件在同一时间)

I would like to know how to solve a problem I've got. I have a Dialog which pops up in an activity. The Dialog doesn't cover the whole screen, so the buttons from the activity still show. I can easily close the dialog when there is a touch outside the dialog's bounds with dialog.setCanceledOnTouchOutside(true); However what I want to do is fire an event if a click is outside the Dialog's bounds(e.g if someone touches a button on the main Activity, it should close the Dialog and fire that event at the same time)

推荐答案

它的工作对我来说,,

Its Works For me,,

        Window window = dialog.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        dialog.show();

请参阅本 <一个href="http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_NOT_TOUCH_MODAL">http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_NOT_TOUCH_MODAL

这篇关于在对话外的Andr​​oid click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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