How to not show overflow menu in the touch a hardware key

82 Views Asked by At

I am using toolbar, add option item in OnCreateOptionsMenu() and set showAsAction="always" so, 3-dot overflow icon does not show. is good work, but show overflow(popup) when i touch the hardware menu key.

I use a hardware key, for other function. How to not show overflow menu in the touch the hardware key?

1

There are 1 best solutions below

0
Andromer On BEST ANSWER

Found. overflow occurred in KeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_MENU){
        work(); //handle
        return true;
    }

    //not menu key
    return super.onKeyUp(keyCode, event);
}

works for me