Yi Xu Chee Yi Xu Chee - 24 days ago 6x
Android Question

How to dynamically change navigation bar item's logo in Java class?

I am integrating Google and Facebook to my application, i.e. I have 2 ways to login in the login page. I have a navigation drawer in the main activity. In the drawer, I have a logout item. I want to be able to set the icon to Google icon or Facebook icon depending on the login method user choose.

For example, if the user logged in with Facebook, the icon of logout button will be a Facebook icon.

Is there a way to somehow set the icon in main activity class? Like

if (loggedInWithFB)


Try this,

NavigationView navigationView = (NavigationView)findViewById(R.id.nav_view);

Hope this helps