/** * 点击弹出 PopupWindow 初始化菜单 */ private void initPopupWindow() { PopupWindowAdapter adapter = new PopupWindowAdapter(); mPopDisplay.setAdapter(adapter); //mPopDisplay 是mPopView 中的listview if (mPopupWindow == null) { // mPopView view对象xml文件 mPopupWindow = new PopupWindow(mPopView, mTopLayout.getWidth(), //mTopLayout控件的宽 ,mPopView是一个xml LayoutParams.WRAP_CONTENT, true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); } if (mPopupWindow.isShowing()) { //开的时候 , 就关闭 mPopupWindow.dismiss(); } else { mPopupWindow.showAsDropDown(mTopLayout, 0, -10); // 设置 ,mTopLayout的下面 } }
时间: 2024-11-08 23:28:07