PopupWindow 放gridView 点击事件 与PopWindow消失逻辑

来源:互联网 发布:西门子828d数控车编程 编辑:程序博客网 时间:2024/06/10 20:37
mPopupWindow.setFocusable(true);//获取焦点 gridview点击事件有效关键mPopupWindow.setBackgroundDrawable(new PaintDrawable());//点击PopupWindow其他地方自动dismis方法mPopupWindow.setTouchable(true);mPopupWindow.setOutsideTouchable(true);mPopupWindow.update();

gridView.setOnKeyListener(new OnKeyListener() {//按下android回退物理键 PopipWindow消失解决@Overridepublic boolean onKey(View v, int keyCode, KeyEvent event) {// TODO Auto-generated method stubif (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {if (mPopupWindow != null && mPopupWindow.isShowing()) {mPopupWindow.dismiss();return true;}}return false;}});


1 0
原创粉丝点击