[英]Popup window dismissal
I was hoping to get the answer for this, I have tried very much to dismiss the popup window when I click outside, but it is not dismissing, anybody know why? 我希望得到答案,当我在外面单击时,我已经做了很多尝试来关闭弹出窗口,但是并没有关闭,有人知道为什么吗? Also it is not going back when I click back button.
当我单击后退按钮时,它也不会返回。
public void onButtonPopup (View target) {
// Make a View from our XML file
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.samplescreens, (ViewGroup) findViewById(R.id.closeLayout));
pwindo = new PopupWindow(layout, width-40, height-(height/4), true);
pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
pwindo.update();
pwindo.setOutsideTouchable(true);
}
public void onButtonInPopup (View target) {
//back_dim_layout.setVisibility(View.GONE);
pwindo.dismiss();
}
One problem from your code is you've written pwindo = new PopupWindow(layout, width-40, height-(height/4), true);
代码中的一个问题是您已经编写了
pwindo = new PopupWindow(layout, width-40, height-(height/4), true);
in which forth parameter is true
ie keep popup window focusable. 其中第四个参数为
true
即使弹出窗口可聚焦。 This is the mistake, as though you say pwindo.setOutsideTouchable(true);
这就是错误,就像您说的是
pwindo.setOutsideTouchable(true);
you've already defined that popup window should be focusable. 您已经定义了弹出窗口应该是可聚焦的。 Make that forth parameter to
false
. 将第四个参数设为
false
。 Still if you're not able to dismiss it, then before dismissing a popup like pwindo.dismiss()
write this line, pwindo.setBackgroundDrawable(new BitmapDrawable(getResources()));
仍然,如果您无法消除它,那么在消除像
pwindo.dismiss()
类的弹出窗口之前,请编写以下行: pwindo.setBackgroundDrawable(new BitmapDrawable(getResources()));
. 。
Hope it helps you. 希望对您有帮助。
Finally solved it! 终于解决了! Changed the order:
更改顺序:
pwindo = new PopupWindow(layout, width-40, height-(height/4), true);
pwindo.setOutsideTouchable(true);
pwindo.setTouchable(true);
pwindo.setBackgroundDrawable(new BitmapDrawable());
pwindo.setTouchInterceptor(customPopUpTouchListenr);
pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
it works now 现在有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.