Detecting Menu Button Being Pressed A Second Time
I am wanting a certain flag in my code to be set when a menu is on screen. I tried catching the keyCode == KeyEvent.KEYCODE_MENU event in onKeyDown to detect when the menu would ap
Solution 1:
To catch the menu being opened, you can override
publicbooleanonPrepareOptionsMenu(Menu menu)
To catch the menu being closed, you can override
publicvoidonOptionsMenuClosed(Menu menu)
However keep in mind that the second one will be called both when the user presses "menu" button the second time or taps one of the menu options. Therefore you'll need to use it in combination with
publicbooleanonOptionsItemSelected(MenuItem item)
Post a Comment for "Detecting Menu Button Being Pressed A Second Time"