Question

I have a button in my screen and i want to open up the menuInflator when the button is pressed i tried the following code but it does not work

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        switch (arg0.getId()) {
          case R.id.btnmenu1:
            // TODO Auto-generated method stub
            MenuInflater inflatemenu = getMenuInflater();
            inflatemenu.inflate(R.menu.bmenu, menu);
            break;
 }

How do i make it work???

Was it helpful?

Solution

Call openOptionsMenu(); method when click on button

or else set android:onClick="myOnClickMethod" on your Button in xml and then have:

public myOnClickMethod(View v) {
    openOptionsMenu();
}

in your activity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top