I am having an optionMenu
at my MainActivity
inflated inside onCreateOptionsMenu
of my MainActivity
and there are some fragments which are inflated inside the MainActivity
which have their own Toolbars
. But the problem is that the OptionMenu
is also visible on the Toolbars
inside the fragments. I don't want the fragments to have the OptionMenu
for Fragments toolbar
setHasOptionsMenu(true)
in your fragment onCreate();
in onCreateOptionsMenu
inflate your fragment menu and remove MainActivity
by using menu.removeItem(R.id.menu_id_to_be_removed);
in onPrepareOptionsMenu