Android: dynamically change ActionBar icon?

后端 未结 4 1683
谎友^
谎友^ 2020-12-23 17:37

I would like to dynamically change the \"home\" icon in the ActionBar. This is easily done in v14 with ActionBar.setIcon(...), but I can\'t find anyway to accomplish this i

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 17:55

    I would say you do something like this :

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_drawer);
    

    see the link How to change the icon actionBarCompat

提交回复
热议问题