简体   繁体   English

在Android中关闭弹出窗口

[英]Closing the Popup Window in Android

IN My App i have shown a popup window at the sametime keybaord is visible on screen when i'm pressing the back button first keyboard is gone and after pressing the back button again poup window get dismissed. 在“我的应用程序”中,我同时显示了一个弹出窗口,同时按下后退按钮时第一个键盘消失了,并且再次按下后退按钮后弹出窗口消失了。 I want to close the popup window first. 我想先关闭弹出窗口。

I have tried to use KeyEvent_BACK but it not working. 我尝试使用KeyEvent_BACK,但无法正常工作。

please provide your suggestions. 请提供您的建议。

mPopUp.setBackgroundDrawable(new BitmapDrawable());
mPopUp.setOutsideTouchable(true);
// display the popup in the center
mPopUp.showAtLocation(layout, Gravity.CENTER, 0, 0);

It works like a champ 它像冠军

mPopUp.setBackgroundDrawable(new BitmapDrawable());

Here, the new BitmapDrawable() is deprecated. 在这里,不推荐使用新的BitmapDrawable()。 Hence, i did it like this popupWindow.setBackgroundDrawable(context.getResources().getDrawable(R.color.transparent)); 因此,我做到了这一点popupWindow.setBackgroundDrawable(context.getResources()。getDrawable(R.color.transparent)); popupWindow.setFocusable(true); popupWindow.setFocusable(true);

And It Works ! 而且有效!

使用dismiss方法隐藏弹出窗口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM