How can I use onCreateOptionsMenu in a Fragment within a tab Activity? (Sherlock ActionBar) How can I use onCreateOptionsMenu in a Fragment within a tab Activity? (Sherlock ActionBar) android android

How can I use onCreateOptionsMenu in a Fragment within a tab Activity? (Sherlock ActionBar)


You need to call setHasOptionsMenu(true) on your fragment before it can participate in the action bar.


May I suggest you check out http://code.google.com/p/sherlock-demo/. As BackpackOnHead describes, it uses ViewPager + ActionBar Tabs to let you navigate two different ways between the Fragments in an Activity. In this case, it is the FragmentTabs portion of the API Demos sample app, ported to ActionBarSherlock. The LoaderThrottle Fragment in particular has its own OptionsMenu items.