[英]How to change bottom navigation icon color if I change Fragment programmatically
I am using bottom navigation to change fragments.我正在使用底部导航来更改片段。 For whatever reason, I need to change Fragment if the user taps a particular button.无论出于何种原因,如果用户点击特定按钮,我需要更改 Fragment。 This method working fine, except a little aesthetic problem.这种方法工作得很好,除了一点审美问题。 If I change fragment programmatically, the bottom navigation icon color won't change.如果我以编程方式更改片段,底部导航图标颜色不会改变。
For handling color change, I am using selector XML right now, but I am ready to use other solutions, to handle this little problem.为了处理颜色变化,我现在正在使用选择器 XML,但我准备使用其他解决方案来处理这个小问题。
please follow this code, it may help you bottomNavigationView.setSelectedItemId(R.id.navigation_home);请遵循此代码,它可能会帮助您 bottomNavigationView.setSelectedItemId(R.id.navigation_home);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.