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

  • Home
  • SEARCH
  • 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 8476623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:13:50+00:00 2026-06-10T18:13:50+00:00

I tried doing this by the book from android dev docs: // this didn’t

  • 0

I tried doing this by the book from android dev docs:

// this didn't create a menu, i don't know why
//registerForContextMenu(getListView());

setListAdapter(new ArrayAdapter<Note>(this, R.layout.selectset_listitem) {
    @Override

    protected View getView(...) {
        ... custom layout ...

        // this creates a menu, but...
        registerForContextMenu(convertView);

        return convertView;
    }
}

And the onCreateContextMenu and onContextItemSelected almost exactly as in http://developer.android.com/guide/topics/ui/menus.html#context-menu.

here is how it looks in the docs (and my code):

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
  super.onCreateContextMenu(menu, v, menuInfo);
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.context_menu, menu);
}

but this part always gives me a null info:

public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    ...
}

The only thing that is really unique is that i’ve got a custom layout for list items (i.e. a couple of text fields and an image). Is there something i need to do to be able to get the index of the list item that the context menu was built for?

  • 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-10T18:13:52+00:00Added an answer on June 10, 2026 at 6:13 pm

    You need to call the registerForContextMenu() in the activity on the ListView, and not on the view items in the adapter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried doing this: [toolbar setTint:[UIColor colorWithPatternImage:[UIImage imageNamed:@thingFromMyBundle.png]]]; but it just ended up black.
what am I doing wrong? Tried this in the console, and yet the typeahead
I'm using devise 2.1.0. On dev, things are great. I just tried doing a
I know this subject has been run into the ground, however I have tried
I'm doing an example from the book: The Complete Reference C# 3.0 by Herbert
I've been following a tutorial from a book on html and css. I tried
I tried doing this in C and it crashes: int nValue=1; void* asd; asd[0]=&nValue;
I tried doing a mvn dependency:tree and I get a tree of dependencies. My
I tried doing var div = document.createElement('div'); var nodeList = new query.NodeList(); nodeList.push(div); nodeList.children(.someClass);
I have two tables: Contestant and Votes Contestant hasMany Votes I've tried doing a

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.