Android - Add Bottom Navigation View Dynamically
I try to add a bottom navigation view dynamically. I know that I add a navigation view inside activity's xml file.
Solution 1:
This is a bug of BottomNavigationView
.
Here is the bug reference: https://issuetracker.google.com/issues/37124043
This has been fixed in support library 25.0.1
. Update your support library
and try again.
Hope this will help~
Solution 2:
try to do this
bottomNavigationView = new BottomNavigationView(ActivityName.this);
or
bottomNavigationView = new BottomNavigationView(getApplicationContext());
Solution 3:
You can define menu xml and inflate it calling inflateMenu method on BottomNavigationView object.
If you need to add any additional menu items, you can do by getting menu object and adding items to menu object.
Menu menu = bottomNavigationView.getMenu();
Post a Comment for "Android - Add Bottom Navigation View Dynamically"