点击弹出窗口外将其关闭

编程入门 行业动态 更新时间:2024-10-28 16:26:55
本文介绍了点击弹出窗口外将其关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复:   How与点击对话外关闭对话框?

我如何可以点击弹出外解雇呢?

How can I click outside of a popup to dismiss it?

下面是我的code:

cell.setOnClickListener(new OnClickListener(){ /*This code is in a separate class so I needed to use ctx as context *and the string "layout_inflater" because it was not recognizing *LAYOUT_INFLATER_SERVICE*/ @Override public void onClick(View arg0) {LayoutInflater layoutInflater = (LayoutInflater)ctx.getSystemService("layout_inflater"); View popupView = layoutInflater.inflate(R.layout.popup_window, null); final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); popupWindow.showAtLocation(newParentLayout, Gravity.CENTER, 0, 0); }

我也尝试添加了这一切,但没有结果。

I've also tried adding all of this but no results.

popupWindow.setTouchable(true); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); Drawable bg = ctx.getResources().getDrawable(R.drawable.popup_bg); popupWindow.setBackgroundDrawable(bg);

我的想法。任何帮助?

I'm out of ideas. Any help?

编辑补充:主要布局是一个ViewPager / PagerAdapter如果这会影响什么

Edit to add: the main layout is a ViewPager/PagerAdapter if that would affect anything?

推荐答案

请设置setOutsideTouchable(真)随着背景。这工作对我罚款。我知道,设置背景绘制为null杀死OnTouchListener。

Please set setOutsideTouchable(true) along with the background. That worked fine for me. I know that setting the background drawable to null kills the OnTouchListener.

更多推荐

点击弹出窗口外将其关闭

本文发布于:2023-08-06 02:16:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1309467.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:将其   弹出窗口

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!