문제

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???

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top