在布局文件(*.xml)中随意选取一个不影响任何操作的 View,推荐使用最外层的 Layout。 然后设置该 Layout 的 Focusable 和 FocusableInTouchMode 都为 true。 获取该 View 的实例,现在你就可以对该 View 重写 OnKeyListener() 事件了 LinearLayout ll_layout = (LinearLayout )view.findViewById(R.id.ll_layout); ll_layout.setOnKeyListener(newOnKeyListener() { publicboolean onKey(View v, intkeyCode, KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) pop.dismiss(); returnfalse; } });
Android中PopupWindow响应返回键并关闭
猜你喜欢
转载自blog.csdn.net/cly19940419/article/details/77816622
今日推荐
周排行