I have a toolbar as well as a navigation drawer. When I start my app, the toolbar and navigation drawer are created. When I click items in the navigation drawer, it starts n
I had the same issue and I wanted to replace the toolbar menu accordingly to the fragment displayed.
The problem I'm now facing is that the menu is added to the previous one.
In order to show only the menu for the fragment, I suggest:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear(); //Empty the old menu
inflater.inflate(R.menu.menu_fragment1, menu);
super.onCreateOptionsMenu(menu, inflater);
}
Hope it'll help.