Android Open menu with button

Is there a way for a button to call up a submenu?

I currently have a menu in which, if they select one of the options, it opens a submenu, however I want to be able to launch a submenu from a Button widget instead of a Menu object.

Thank!

+5
source share
3 answers

I do not necessarily recommend this, but I was able to program the submenu. First, in overriding onCreateOptionsMenu, I saved the menu setting to a personal Menu variable in action. Then I was able to just do the following from onClick ():

MyActivity.this.openOptionsMenu(); // activity onCreateOptionsMenu gets called
optionsMenu.performIdentifierAction(R.id.miSubMenu1, 0);

, , .

+26

openOptionsMenu() , , .

+2

I am not sure if this is possible. One option is to use the dialog box as a submenu so you can open it from anywhere.

0
source

All Articles