Android has new ui element - BottomNavigationView
I don't want to contain my menus in the xml files. I will receive the information about menu items and order from backend side. I want to create them dynamically and set into the BottomNavigationView
in the onCreate()
method. Can I do this?
The easy way to use dynamic options in bottom navigation view is use different menu items like this:
By default,
BottomNavigationView
starts with an empty menu. You can use thegetMenu()
method to get the Menu instance, then add menu items as in the response above. For example,Heres an example of dynamic build of menu items, in the main activity u have 2 layouts. you can get your own layout from your backend and create menu items dynamically using menu.add
src: http://www.mobiledevguide.com/2014/01/dynamically-create-menu-items-in-android.html