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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:58:00+00:00 2026-06-17T14:58:00+00:00

I have a ListView filled with items. I’d like to set an onClickListener to

  • 0

I have a ListView filled with items. I’d like to set an onClickListener to show details about the item that was clicked. How can I determine which item was clicked within the onClickListener? The View, or v has a lot of methods available that I’ve looked through and don’t see anything pertaining to getting the object clicked on.

    //populate the activity list
    ListView teamsListView = (ListView) activity.findViewById(R.id.teamsListView);
    ArrayList<HashMap<String, String>> listData = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> listItem;
    for (TeamSet teamSet : response.getTeamSetList()) {
        listItem = new HashMap<String, String>();
            listItem.put("name", teamSet.getName());
            //listItem.put("teamCount", Integer.toString(teamSet.getTeams().size()));

        listData.add(listItem);
    }
    teamsListView.setAdapter(
            new SimpleAdapter(
                    context,
                    listData,
                    R.layout.teams_list_row,
                    new String[]{"name"},
                    new int[]{R.id.teamsTeamListName}
            )
    );

    //show details on a team
    TextView team = (TextView) activity.findViewById(R.id.teamsTeamListName);
    team.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //how do I know which item was clicked?  I want to load more details on the item...
        }
    });
  • 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-17T14:58:02+00:00Added an answer on June 17, 2026 at 2:58 pm

    You use a OnItemClickListener not a onCLickListener

    You do something like this:

    final ListView lv = (ListView) findViewById(R.id.ListView01);
    
    lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
            String selectedFromList =(String) (lv.getItemAtPosition(myItemInt));
    
          }                 
    });
    

    Hope this helped.

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

Sidebar

Related Questions

I have an android listview filled with items. Every item has a button. This
I have a listview (in Details view) that is filled dynamically. I want to
I have a ListView that is filled with a dynamic set of data each
I have a ListView that is filled with items of an ArrayAdapter. Now I
I have ListVIew that is filled with hard-coded DataModel . Then I want to
I have a list of items, which i'd like to check with filled star
I have a ListView that is filled by an ObservableCollection<MenuTrayItem> . In my resources
My question is;I have a listview which can be filled through a code.I put
I have a ListView that looks like this: The combo box is bound to
I have a sortable listview that gets filled with a live data as it

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.