You must call it setHasOptionsMenu();using the trueargument passed to it, then you can override the Create Link options menu.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
If you want to have different Menu parameters for each fragment, you will define two different xml files and inflate them into onCreateOptionsMenu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment1_menu, menu);
}
source
share