辞退PopupWindow上弹出外触控,无需使用pcated德$ P $构造 [英] Dismiss PopupWindow on touch outside popup, without using deprecated constructor

查看:108
本文介绍了辞退PopupWindow上弹出外触控,无需使用pcated德$ P $构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PopupWindow,我想,当用户触摸外面解雇,所以我调查并发现,我不得不使用 popup.setBackgroundDrawable(新BitmapDrawable()); 。问题在于构造新BitmpaDrawable()是德precated。我想找到一个解决方案,而无需使用它。

任何人知道如何解决此问题?

谢谢!

 最后PopupWindow弹出=新PopupWindow(sortByView,
                                          ViewGroup.LayoutParams.WRAP_CONTENT,
                                          ViewGroup.LayoutParams.WRAP_CONTENT,
                                          真正);
                popup.setBackgroundDrawable(新BitmapDrawable());
                popup.setOutsideTouchable(真正的);
                popup.showAsDropDown(五);
 

解决方案

我不得不这样做,以得到它的工作:

  popup.setBackgroundDrawable(新ColorDrawable(android.R.color.transparent));
popup.setOutsideTouchable(真正的);
 

I have a PopupWindow and I wanted it to dismiss when the user touches outside, so I looked into and found out that I had to use popup.setBackgroundDrawable(new BitmapDrawable());. The problem is that the constructor new BitmpaDrawable() is deprecated. I Would like to find a solution without using it.

Anybody knows how to solve this?

Thanks!

                final PopupWindow popup = new PopupWindow(sortByView,
                                          ViewGroup.LayoutParams.WRAP_CONTENT,
                                          ViewGroup.LayoutParams.WRAP_CONTENT,            
                                          true);
                popup.setBackgroundDrawable(new BitmapDrawable());
                popup.setOutsideTouchable(true);
                popup.showAsDropDown(v);

解决方案

What I had to do to get it to work:

popup.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
popup.setOutsideTouchable(true);

这篇关于辞退PopupWindow上弹出外触控,无需使用pcated德$ P $构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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