Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9171163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:07:32+00:00 2026-06-17T16:07:32+00:00

I have a class that extends SherlockActivity because I’m using an ActionBarSherlock action bar

  • 0

I have a class that extends SherlockActivity because I’m using an ActionBarSherlock action bar in the activity. However, I’m also trying to add a context menu to a listview in this activity that launches when an item in the listview is longpressed. I’m getting an error in my declaration of onContextItemSelected(MenuItem item) that says that my override is invalid because there’s nothing to override. However, when I remove the override, the function is never called. I know this has something to do with the way SherlockActivity inherits from Activity but I’m not sure about the specifics. Maybe I’m missing an import? See the relevant code here:

public class Inbox extends SherlockActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inbox);
    refreshMsgs(this.getCurrentFocus());
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.getId() == R.id.lstInbox){
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        String contactName = lstConversation.get(info.position).getContactName();   
        menu.setHeaderTitle(contactName);
        menu.add(Menu.NONE, 0, 0, "View contact");
        menu.add(Menu.NONE, 1, 1, "Delete thread");
    }
}

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    SmsConversation selectedConvo = lstConversation.get(info.position);         

    if (item.getItemId() == 0){
        //view contact
        Intent viewcontactIntent = new Intent();
        String contactId = selectedConvo.getContactId();
        Uri uriContact = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contactId);
        viewcontactIntent.setData(uriContact);
        PendingIntent pViewIntent = PendingIntent.getActivity(getBaseContext(), 1, viewcontactIntent, 0);
        try {
            pViewIntent.send();
        } catch (CanceledException e) {
            e.printStackTrace();
        }
    } else {
      //DELETE thread
    }
    return true;
}
}

And here are all of my imports for the class:

import java.util.ArrayList;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuInflater;

import android.app.Activity;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.Html;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:07:33+00:00Added an answer on June 17, 2026 at 4:07 pm

    Faced with a similar issue a long time ago, I have overriden onContextItemSelected() by forcing the normal MenuItem using its fully qualified class name (android.view.MenuItem), like so:

    @Override
    public boolean onContextItemSelected (android.view.MenuItem item)
    {
      //implementation
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that extends View (MyView extends View) In Activity I have
I have a class that extends generic class that also extends (another) generic class.
I have a BaseActivity class that extends Activity, in it I have @Override public
I have a class that extends Activity and inflates another xml layout in the
I have class that extends Activity. That has a Logout menu options. When I
I have a class that extends Activity like so: public abstract class AndroidGame extends
I have a class that extends Activity and implements ViewFactory. I have found some
I have a class that extends Activity and within it got a private class
Using .NET 4, C# Let's say I have class Info that extends CustomTypeDescriptor .
I am using NetBeans, and I have a class that extends to JDialog, inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.