I have a problem, I want to add an item to the toolbar (material design) programmatically.
This is my menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> <item android:id="@+id/action_settings" android:title="@string/action_settings" android:orderInCategory="100" android:showAsAction="never" /> </menu>
I know that you change text, color, background and @override listener
toolbar.setBackgroundColor toolbar.setTextColor toolbar.setNavigationIcon toolbar.setText
I do not know how to add a menu with the category " android:orderInCategory="300 "
Thanks.
Note: I have the whole fragment, without 1 activity
Tree - > Activity - > Fragment1(here add menu item) - > Fragment2(add/remove menu item) - > Fragmentx ..
user5147656
source share