0

I want to change the icon of my BottomNavigationView after it got initialized. If I do it at onCreate it works fine. But I have to do it after getting an asynchronous response from the server.

val menuItem = bottom_navigation.menu.findItem(R.id.nav_item_4)
menuItem.icon = ContextCompat.getDrawable(this, R.drawable.ic_nav_message)
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
King Bufo
  • 181
  • 1
  • 13

1 Answers1

0

this can give you the option to change the icon in runtime.

MenuItem logOut= nav_Menu.findItem(R.id.nav_logOut);
logOut.setIcon(*here you can give the path of your icon*);
Hasnain Sabir
  • 200
  • 1
  • 7
  • It only works like that when i call it before the OnNavigationItemSelectListener gets initialized and my async call comes way later. – King Bufo Sep 05 '19 at 15:46