How to reject ContextMenu without the back button?

The application has a context menu open, and I want to close it / turn it off without using the "Back" button. Is it possible to get a click event somewhere so that I can call close?

closeContextMenu ()

Or can I call

setCancelOnTouchOutside()

anywhere how can i in a dialogue? An alternative for me is to refactor my entire context menu in PopupWindows, which can also do

setOutsideTouchable()

Any good hint / idea?

+3
source share
2 answers

send the key event (back), and you're done.

myView.getRootView().dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
+1
source

, , , ""?

0

All Articles