Trying to hide and show menu items on action bar

后端 未结 4 993
灰色年华
灰色年华 2021-02-05 19:26

I have looked through the questions on stack overflow and can\'t find the solution.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuInflater i         


        
4条回答
  •  春和景丽
    2021-02-05 20:14

    Try this in your FragmentActivity

    public boolean onPreparePanel(int featureId, View view, Menu menu) {
        if(isLeftMenuOpened()) return false;
        return super.onPreparePanel(featureId, view, menu);
    }
    

    Method FragmentActivity.onPreparePanel creates menu for all attached fragments. You must return true for the menu to be displayed; if you return false it will not be shown.

提交回复
热议问题