The way you want to have an options menu in a particular tab fragment is not creating the options menu in the activity then hide/show it.
Instead of calling onCreateOptionsMenu() inside the Activity, call onCreateOptionsMenu() inside a fragment:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
}
and don't forget to add this
@Override
public void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
to the fragment.