I using menu drawer which has more Fragment
s. In some Fragment
s I have menu item REFRESH but in some fragments I want hide this menu item (I don\'t
Firstly in your Activity
that has the toolbar, create a method that sets up the overflow menu
for you:
public void setUpOptionMenu(Toolbar toolbar){
this.setSupportActionBar(toolbar);
}
In your fragments onCreateView()
method, get the reference of your current activity and call your activities setUpOptionMenu()
method:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
...
...
public void ((YourActivityName)this.getActivity()).setUpOptionMenu(null);
...
...
}
Cheers!!!