How can I refresh the ActionBar when onPrepareOptionsMenu switched menu entries?

后端 未结 10 1440
予麋鹿
予麋鹿 2020-12-02 12:05

Within my apps I often enable/disable menu entries and do make them visible from onPrepareOptionsMenu.

Today I started to add the android:showAsAction menu attribute

10条回答
  •  长情又很酷
    2020-12-02 12:32

    I am not sure you have seen it already, but if you use the actionbar extensively, and plan on supporting lower API's (>8), take a look at the actionBarSherlock library. It will make it so you do not have to section your actionBar code for lower and Higher API's, and then you can just run:

    runOnUiThread(new Runnable(){
      @Override
      public void run(){
        supportInvalidateOptionsMenu();
      }
    });
    

提交回复
热议问题