How can I change Action Bar actions dynamically?

前端 未结 4 772
南笙
南笙 2020-11-29 23:38

I have an Activity with ActionBar and tab navigation. I am using the split mode, so the tabs are at the top and actions are in the bottom bar. How can I dynamically change t

4条回答
  •  野性不改
    2020-11-30 00:24

    Activity.invalidateOptionsMenu() requires API Level 11. There is a simpler solution which is backwards compatible:

    Add the MenuItem to the Menu initially but set its visibility to false. Set visibility to true when desired, using MenuItem.setVisible()

提交回复
热议问题