如何明确摆脱选项菜单图标?

如何明确摆脱选项菜单图标?

问题描述:

我看着在Android菜单项,看到清晰的()将从菜单中删除所有现有的项目,留下空的,就好像它刚刚被创建。这个工作正常,我但选项菜单图标仍然存在。不应该,如果菜单为空的图标也消失了吗?(我不得到仍然有它的理由)有没有一种方法,使图标消失?

I looked on the android menu item and saw that clear() will "Remove all existing items from the menu, leaving it empty as if it had just been created." this works fine for me but the options menu icon is still there. Shouldn't the icon also disappear if the menu is empty?(i don't get a reason for still having it) Is there a way to make the icon disappear?

设置在XML无形溢出菜单项:

Set the overflow menu item invisible in the xml:

<item android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:orderInCategory="100"
    app:showAsAction="never"
    android:visible="false"/>

或者说onCreateOptionsMenu其删除:

Or remove it at onCreateOptionsMenu:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    menu.findItem(R.id.action_settings).setVisible(false);

    return true;
}