Unable to override onCreateOptionsMenu in ListFragment Unable to override onCreateOptionsMenu in ListFragment android android

Unable to override onCreateOptionsMenu in 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.


I had a similar issue using the SherlockActionBar on my activity. Here was my setup that fixed the problem:

import com.actionbarsherlock.app.SherlockActivity;import com.actionbarsherlock.view.Menu;public class LoginActivity extends SherlockActivity{    ...    @Override    public boolean onCreateOptionsMenu(Menu menu){        getSupportMenuInflater().inflate(R.menu.activity_login, menu);        return true;    }    ...}