3

The application has a contextmenu opened and I want to close/dismiss it without using the back button. Is it possible to receive a click event somewhere so I can call close?

closeContextMenu ()

Or can I call

setCancelOnTouchOutside()

somewhere like I can on a Dialog? Alternative for me is to refactor all my context menu's to PopupWindows which can also do

setOutsideTouchable()

Anyone a good hint/idea?

4

2 回答 2

1

dispatch a key event (back)and you're done.

myView.getRootView().dispatchKeyEvent(new KeyEvent (KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
于 2012-05-22T12:33:28.370 回答
0

It sounds like you're describing a cancel listener type of behavior like you'd use in a dialog, but why not just use the back button?

于 2012-10-23T16:09:55.917 回答