I have a main activity that does not use option menu. I need to implement this behavior: 1. When the Android Menu button is pressed, a popup is shown 2. When the Android Menu button is pressed again, the popup is dismissed.
I know how to do #1 by overriding onKeyDown() in the main activity but don't know how to do #2. When the popup is shown, the onKeyDown() of the main activity is not triggered anymore.
How do I capture the Android Menu button when the main activity has an open popup? (in my case, the popup is a PopupWindow with an inflated view).
BTW, I tried to set a key listener on the main view of the popup but it is not triggered
mTopView.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
LogUtil.debug("*** Key: %d", keyCode);
return false;
}
});