I created an app that supports both phone and tablet version so i use the android-support-v4.jar library.
My activity extends the ListFragment and I tried to overri
I had the same problem and this what I did to use onCreateOptionsMenu of Fragment. Override the onCreate method of the Fragment and make sure that you use setHasOptionsMenu method with parameter value "true" to let the system know Fragment will use OptionsMenu.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
Then override onCreateOptionsMenu to inflate your menu xml file (here in this example I inflated fragmentmenu.xml
@Override
public void onCreateOptionsMenu (Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragmentmenu, menu);
}