Inflate Bottom Navigation View menu programmatically

前端 未结 2 1380
臣服心动
臣服心动 2020-12-17 16:24

Bottom Navigation View has been added to version 25 of the Design Support Library. Tried and it\'s much easier to use now.

But I am facing problem implementing it a

相关标签:
2条回答
  • 2020-12-17 17:07
    navigationView.getMenu().clear(); //clear old inflated items.
    navigationView.inflateMenu(R.menu.new_navigation_drawer_items);
    

    from this answer

    0 讨论(0)
  • 2020-12-17 17:16
    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    
    //Add MenuItem with icon to Menu
    navigation.getMenu().add(Menu.NONE, 1, Menu.NONE, "Home").setIcon(R.drawable.ic_home_black_24dp);
    

    Hope it helps.

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