android – PopupWindow如何获得被触及的外部事件的通知?

android – PopupWindow如何获得被触及的外部事件的通知?,第1张

概述该文档指出PopupWindow将在其窗口之外被告知触摸事件 setOutsideTouchable(boolean touchable)设置为true. popupwindow如何通知?我没有看到任何像setOnOutsideTouchListener等的监听器来接收该信息. 例 PopupWindow popup = new PopupWindow();popup.setOutsideTou 该文档指出PopupWindow将在其窗口之外被告知触摸事件
setoutsIDetouchable(boolean touchable)设置为true.
popupwindow如何通知?我没有看到任何像setonOutsIDetouchListener等的监听器来接收该信息.

PopupWindow popup = new PopupWindow();popup.setoutsIDetouchable(true);//Now what..how to receive those touch outsIDe events?

谢谢.

解决方法 尝试使用settouchInterceptor,如下面的代码片段
popup.settouchInterceptor(new OntouchListener()     {        public boolean ontouch(VIEw v,MotionEvent event)         {            if (event.getAction() == MotionEvent.ACTION_OUTSIDE)             {                popup.dismiss();                return true;            }            return false;        }    });

也不要忘记设置以下标志:

popup.setoutsIDetouchable(true);
总结

以上是内存溢出为你收集整理的android – PopupWindow如何获得被触及外部事件的通知?全部内容,希望文章能够帮你解决android – PopupWindow如何获得被触及的外部事件的通知?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1131098.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存