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 override the onCreateOptionsMenu(Menu menu, MenuInflater inflater), as in the following link: http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentMenuSupport.html
I previously called setHasOptionsMenu.
Unfortunately, it seems that I cannot override onCreateOptionsMenu().
This is the error message:
The method onCreateOptionsMenu(Menu menu, MenuInflater inflater) of type MyFragment must override or implements a supertype method.
And I did that with:
Public class MyFragment extends ListFragment
Make sure the imports are from the compatibility library and not from the SDK itself.
OK, I just had this same problem, although it wasn't fixed by what is here. I'm using the ActionBarSherlock library and it turns out that onCreateOptionsMenu
wants Menu
to be from android.support.v4.view.Menu
and MenuInflater
to be from android.view.MenuInflater
, not android.support.v4.view.MenuInflater
. Don't ask me why. I don't know if this will fix everyone, so I'll share how I figured it out:
Right click the blank space where you'd like the method to be in Elcipse > Source > Overide/Implement methods...
Then just find it from here, and Eclipse will automatically import the correct things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With