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 9265763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:09:22+00:00 2026-06-18T14:09:22+00:00

I am using the android List View in my activity … Now i need

  • 0

I am using the android List View in my activity …

Now i need get the name for the item selected from the list…

here’s my code for menu create

public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
       super.onCreateContextMenu(menu, v, menuInfo);         


     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.activity_main, menu); //select layout which should pop up in context menu

     menu.add("Delete");
     menu.add("Rename");

}

what i need is the way to get the list view selected item’s name in the following function which captures the click on Context menu.

@Override
public boolean onContextItemSelected(MenuItem item) 
{

     super.onContextItemSelected(item);


    if(item.getTitle()=="Delete"){
       //slected item's name in string varible here??
    }
    if(item.getTitle()=="Rename"){
            //slected item's name in string varible here??
    }
    return true;

}
  • 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-18T14:09:24+00:00Added an answer on June 18, 2026 at 2:09 pm

    to get the itemId use this:

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    

    you can get the id of an item via

    info.id
    

    If you want to receive the name, you can also use to info.position to get the position of the item in the list. With the position you can get the item from the listView to get the name of the item

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

Sidebar

Related Questions

I am using a list view in Android 1.5 to show a list of
I am creating a app in android. In that i am using list view.
I'm using ListFragment and implementing LoaderManager.LoaderCallbacks from Android compatibility package for showing a list
Using Android opengl I need to move an object from point A to point
I have an android activity that consists of a List View and a Text
in my android app i am using expandable list view to display some text.These
I'm trying to get the position of a list view in android development. I
Got a little problem. I'd like to create an android list view activity with
friends, i am using following tutorial to lazy load list view now problem is
I make List view with image and text using simple adapter in android. But

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.