Android settings menu is always closed

I would like to know how to prevent the menu bar from closing.

@Override
public void onOptionsMenuClosed(Menu menu) {

}

When the action begins, I open the menu and want it to remain open.

    new Handler().postDelayed(new Runnable() {
        public void run() {
            openOptionsMenu();
        }
    }, 1000);
+1
source share
1 answer

You cannot open the options menu, and it will always act in this way. But you can create your own menu in the .xml layout and set the visibility of GONE. Then override the onKeyDown () method and listen for the menu key presses. If it is pressed, the parameter menu will be set to open / close (VISIBLE / INVISIBLE) depending on its current state. This way you can control whether the options menu remains open or even after touching.

+2
source

All Articles