How to dynamically hide a menu item in BottomNavigationView?

后端 未结 9 1512
佛祖请我去吃肉
佛祖请我去吃肉 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:51

    Try this:

    navView.getMenu().findItem(R.id.your_menu_item_id).setVisible(true);
    navView.getMenu().findItem(R.id.your_menu_item_id).setVisible(false);
    
    0 讨论(0)
  • 2020-12-30 20:52

    In Kotlin you can use this line of code:

     mainActivitbinding.bottomNav.menu.removeItem(R.id.watch_list_tab)
    
    0 讨论(0)
  • 2020-12-30 21:00

    I tried most of solutions but this worked for me,

    For hiding an item dynamically : bottomNavigationView.findViewById(R.id.xyz).setVisibility(View.GONE);

    For making item visible: bottomNavigationView.findViewById(R.id.xyz).setVisibility(View.VISIBLE);

    0 讨论(0)
提交回复
热议问题