In the layout file (*.xml), choose a View that does not affect any operations. It is recommended to use the outermost Layout. Then set both Focusable and FocusableInTouchMode of the Layout to true. Get the instance of the View, now you can override the OnKeyListener() event for the View 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; } });
PopupWindow in Android responds to return key and closes
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325941228&siteId=291194637
Recommended
Ranking