android: changing option menu items programmatically

前端 未结 12 1875
终归单人心
终归单人心 2020-12-02 09:33

Is it possible to change the option menu items programmatically? Can anyone provide me with an example please?

Also, I want to disable certain items, so that they do

12条回答
  •  离开以前
    2020-12-02 10:11

    Like Nikolay said do that in onPrepareOptionsMenu().

    For menu items in the action bar you have to invalidate the menu with activity.invalidateOptionsMenu();

    This is descriped in more detail here How can I refresh the ActionBar when onPrepareOptionsMenu switched menu entries?

提交回复
热议问题