gpt4 book ai didi

android - 在弹出窗口外单击以关闭它

转载 作者:太空狗 更新时间:2023-10-29 15:42:41 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to dismiss the dialog with click on outside of the dialog?

如何在弹出窗口外单击以关闭它?

这是我的代码:

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);
}

我也尝试添加所有这些但没有结果。

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

我没主意了。有帮助吗?

编辑添加:主布局是 ViewPager/PagerAdapter,如果这会影响什么?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com