Google Groups

Re: onContextItemSelected Not Called When Including ABS

Jake Wharton Jan 11, 2012 8:29 AM
Posted in group: ActionBarSherlock
You'll have to specify the full package for one of them.



class Whatever extends FragmentActivity {
    public boolean onOptionsItemSelected(MenuItem item) {
        /* ... */

    public boolean onConextItemSelected(android.view.MenuItem item) {
        /* ... */

Jake Wharton

On Wed, Jan 11, 2012 at 11:25 AM, Rob Isakson <> wrote:
Ahh that makes sense, but now onOptionsItemSelected is erroring, stating "Cannot override the final method from FragmentActivity", even though I am not @Override'ing that method.

Rob Isakson

PogramarProgramerProgramor. I write code.

On Wed, Jan 11, 2012 at 10:12 AM, Jake Wharton <> wrote:
You callback should explicitly be using android.view.MenuItem for context menu callbacks and not (which I'm going to assume is imported for normal options menu usage). If you add an @Override annotation to the callback you can ensure you're using the right type.

Jake Wharton

On Wed, Jan 11, 2012 at 11:02 AM, Rob Isakson <> wrote:
So I've experienced this in 2 separate applications. After adding adding ActionBarSherlock to the project and adding an action bar to the activity, the onContextItemSelected never gets fired when an item is clicked from a long press context menu. I've tried a bunch of different things from my various googlings, but nothing seems to work. Any thoughts?

ListView list = (ListView) findViewById(;
list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
menu.add(0, CONTEXT_EDIT, 0, "Edit");
menu.add(0, CONTEXT_DELETE, 1, "Delete");

public boolean onContextItemSelected(MenuItem item) {
Log.d("debug", "onContextItemSelected-item.getItemId():" + item.getItemId());