How to dynamically hide a menu item in BottomNavigationView?

后端 未结 9 1572
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 20:04

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

mBottomNavigationView.g         


        
9条回答
  •  星月不相逢
    2020-12-30 20:37

    It works for me in kotlin like this:

    bottomNavigationView.rootView.findViewById(R.id.nav_nearestRestaurant).visibility = View.GONE
    

    But the thing is that if you click in another item, the hidden item appears again, because the bottom bar reload its appearance when show you the active item (so if in your xml menu, its visible, appears visible again (I think, to me happen like that))

提交回复
热议问题