0

It's my understanding that in a normal FragmentActivity / ViewPager / FragmentStatePagerAdapter situation onCreateOptionsMenu should be handled by the ListFragment... ...but what about in a scenario where ActionBarSherlock is extending the FragmentActivity and ListFragment classes?

I'm having a hard time getting onCreateOptionsMenu to work in the SherlockListFragment:

  1. The ABS version of onCreateOptionsMenu is boolean, not void.
  2. The ABS version of onCreateOptionsMenu omits MenuInflater as a parameter
  3. Instantiating MenuInflater in SherlockListFragment.onCreateOptionsMenu is a problem ("Inflater cannot be resolved to a type").

I would be grateful if anyone could show me what I'm doing wrong...

Thanks!

Quasaur
  • 1,335
  • 1
  • 10
  • 27

1 Answers1

0

You should definitely be able to override void onCreateOptionsMenu(Menu menu, MenuInflater inflater) in SherlockListFragment. I've had issues in the past where I imported the wrong MenuInflater. Could that be what's going wrong? You want to import com.actionbarsherlock.view.MenuInflater instead of android.view.MenuInflater.

Also, be sure to use getSupportMenuInflater over getMenuInflater when using ABS.

Matthew
  • 6,356
  • 9
  • 47
  • 59
  • Thank you for replying but I've done all of that. In the pattern that I'm using FragmemtStaticPager and SherlockListFragment are static nested classes...calling the OptionsMenu methods from within SherlockListFragment return errors. – Quasaur Feb 22 '13 at 14:33
  • @Quasaur can you post a minimal code example of what you're doing? It would help with finding what the issue is. – Matthew Feb 22 '13 at 18:46
  • I used the following link as the template for my implementation: https://github.com/JakeWharton/ActionBarSherlock/blob/master/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentStatePagerSupport.java – Quasaur Feb 25 '13 at 02:06
  • ...this example doesn't have any menu system...where would you put the OptionsMenu callbacks in this file? – Quasaur Feb 25 '13 at 02:07