Android 如何在pw.setfocusable(true)时隐藏弹出窗口?
当我打开弹出窗口时,我不能关闭它,因为我使用了popupwindow.setfocusable(true)。如果我不使用Focusable,我就不能打开网格视图的项Android 如何在pw.setfocusable(true)时隐藏弹出窗口?,android,gridview,popupwindow,optionmenu,Android,Gridview,Popupwindow,Optionmenu,当我打开弹出窗口时,我不能关闭它,因为我使用了popupwindow.setfocusable(true)。如果我不使用Focusable,我就不能打开网格视图的项 LayoutInflater layoutInflater = (LayoutInflater) getBaseContext() .getSystemService(LAYOUT_INFLATER_SERVICE); popupView = layoutInflater.inflate(R.layo
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
popupView = layoutInflater.inflate(R.layout.gridview_popup, null);
gridViewPopup = (GridView) popupView.findViewById(R.id.gridViewPopup);
mCategoryAdapter = new CategoryAdapter(MainActivity.this);
gridViewPopup.setAdapter(mCategoryAdapter);
popupWindow = new PopupWindow(popupView, LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
在这里,我设置used Focusable(真)
通过使用此按钮,我不能错过同一按钮上的弹出窗口
if (popupShowing == false) {
popupWindow.showAsDropDown(findViewById(R.id.category_list), 0,
0);
popupShowing = true;
} else {
popupWindow.dismiss();
popupShowing = false;
您必须设置popupWindow.setOutsideTouchable(true)这对我有用。如果我使用popupWindow.setOutsideTouchable(true),未检测到网格视图项目的单击事件。。