I have 3 Fragment
s which, in a normal (small) layout are all in separate Activities. They should provide an optionsmenu in the small layout.
In the large layout, I have the 3 fragments in one Activity, causing the menu to fill with the buttons inflated by all three fragments. How can I prevent this, and only let the Activity inflate the optionsmenu, while still holding the functionality on smaller devices?
-Edit-
So each Fragment uses the following code:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
/* Some code */
setHasOptionsMenu(true);
/* Some code */
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
inflater.inflate(R.menu.mymenu, menu);
}
When all three Fragments are shown, all Fragments execute onCreateOptionsMenu()
and all items appear three times.
What I want is for the parent Activity
to take the responsibility of creating the options menu.