The standard functionality on Android devices makes the software keyboard popup every time the Menu is long pressed. This may be annoying or unwanted. To disable this default functionality, all one needs to do is to intercept the Menu key down event.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (!b.isChecked())
return super.onKeyDown(keyCode, event);
if (keyCode == KeyEvent.KEYCODE_MENU) {
return true;
}else return super.onKeyDown(keyCode, event);
}
If the checkbox is on, the MENU long press will be overridden and the keyboard won’t open. A side effect is that also short MENU presses won’t work anymore (like when trying to open a predefined application menu). Source code: OverridingMenu |