Search code examples
javaandroidmenu

How to keep overflow menu open


I am stuck with this: I have Google map with Markers and I have sort of filters in the overflow menu which has checkable item so when an item is clicked it will set or unset the visibility of some markers.

My issue is when I click, the overflow menu autocloses.

My question is: Is it possible to keep the overflow menu open and close it when you click outside of it?

Thanks!


Solution

  • You could try overriding onOptionsMenuClosed() and reopening the menu as soon as it closes.

    @Override
    public void onOptionsMenuClosed(Menu menu) {
      //openOverflowMenu();
    }
    

    Otherwise, you could try the answer here using a customView and essentially you'd control when to show or hide the menu.