简体   繁体   中英

Changing/removing items of Bottom bar in android

I have an activity with a BottomNavigationView , I need to switch items (remove old and add new ones) of my bottomNavigationView when a button is clicked. I tried all these options but none of them is working:

 bottomNavigationView.getMenu().clear();
   bottomNavigationView.getMenu().getItem(0).setVisible(false);
   bottomNavigationView.getMenu().removeItem(0);       bottomNavigationView.removeViewInLayout(bottomNavigationView.findViewById(R.id.explore_item));

I tried using the roughike bottom bar and could find a way to switch bottom bar items with a click.

I ended up implementing the worst solution : adding two BottomNavigationViews and switching their visibilty ! The problem is I need to switch bottom bar items more than once, and I cant keep adding bottomNavViews to my ui !

Any help with switching bottom bar items on a button click would appreciated. Thanks.

我找到的唯一解决方案是使用

bottomNavigationView.getMenu().removeItem(R.id.menu_item);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM