private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment fragment;
switch (item.getItemId()) {
case R.id.navigation_lang:
toolbar.setTitle("Language");
fragment = new LangFragment();
loadFragment(fragment);
return true;
case R.id.navigation_paid:
toolbar.setTitle("Paid");
fragment = new PaidFragment();
loadFragment(fragment);
return true;
case R.id.navigation_unpaid:
toolbar.setTitle("UnPaid");
fragment = new UnpaidFragment();
loadFragment(fragment);
return true;
case R.id.navigation_declined:
toolbar.setTitle("Declined");
fragment = new DeclinedFragment();
loadFragment(fragment);
return true;
}
return false;
}
};
如何在片段中的菜单图标上添加徽章。我尝试了更多的例子,但所有的活动都需要在片段中实现。如何在菜单上实现徽章的xml。我也添加了图像。这是我的工具栏menu.please帮助如何做到
答案 0 :(得分:1)
最简单的方法是使用像这样的库 https://github.com/aurelhubert/ahbottomnavigation
您可以在底部导航图标
上轻松显示通知bottomNavigation.setNotification("1", 3);
在此处阅读更多内容:https://github.com/aurelhubert/ahbottomnavigation/blob/master/README.md