How to dynamically hide a menu item in BottomNavigationView?

Ram picture Ram · Jul 12, 2017 · Viewed 22.4k times · Source

I want to hide a menu item of BottomNavigationView dynamically based on some conditions. I tried the following but it is not working.

mBottomNavigationView.getMenu()
            .findItem(R.id.item_name)
            .setVisible(false);

mBottomNavigationView.invalidate();

Answer

Ram picture Ram · Jul 12, 2017
mBottomNavigationView.getMenu().removeItem(R.id.item_name);

removeItem does the trick. Not sure why setVisible method is not working.