[英]Changing/removing items of Bottom bar in android
我有一个带有BottomNavigationView的活动,我需要在单击按钮时切换我的bottomNavigationView的项目(删除旧的并添加新项目)。 我尝试了所有这些选项,但它们都没有工作:
bottomNavigationView.getMenu().clear();
bottomNavigationView.getMenu().getItem(0).setVisible(false);
bottomNavigationView.getMenu().removeItem(0); bottomNavigationView.removeViewInLayout(bottomNavigationView.findViewById(R.id.explore_item));
我尝试使用粗糙的底栏 ,可以找到一种方法来点击切换底部条形项目。
我最终实现了最糟糕的解决方案:添加两个BottomNavigationViews并切换它们的可见性! 问题是我需要不止一次切换底部条形项目,我不能继续向我的ui添加bottomNavViews!
任何有关按钮点击切换底栏项目的帮助将不胜感激。 谢谢。
我找到的唯一解决方案是使用
bottomNavigationView.getMenu().removeItem(R.id.menu_item);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.