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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:30:33+00:00 2026-05-20T06:30:33+00:00

I have an activity in Android which uses a ListView. When I click on

  • 0

I have an activity in Android which uses a ListView. When I click on an item in the ListView, I would like to be able to determine which item was clicked. I have the following code:

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    setContentView(R.layout.listr);

   //setupDB();  
   //populateList3();
   ListView lv = (ListView) findViewById(R.id.ListView01);
   lv.setClickable(true);

   lv.setOnItemClickListener(new OnItemClickListener() {

   public void onItemClick(AdapterView<?> parent, View view, int position, long id) {      
        Toast.makeText(ListRecords.this,"Clicked!", Toast.LENGTH_LONG).show();
       }
   });

}

My layout.xml:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  

     android:id="@+id/Linear03lr"
     android:layout_width="fill_parent"  
     android:orientation="vertical"  
     android:gravity="center"
     android:layout_height="fill_parent">  


 <!--Put form controls here-->  
    <ListView android:id="@+id/ListView01"

 android:layout_width="wrap_content"
 android:layout_height="400dp" />

     <Button
        android:id="@+id/previousbutton"
        android:gravity="center_horizontal"
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent"

        android:text="Previous Menu"/>
</LinearLayout>  

What am I missing here to be able to intercept clicks on the 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-05-20T06:30:33+00:00Added an answer on May 20, 2026 at 6:30 am

    It might be easier to use ListActivity, then you simply have to over-ride onListItemClick.

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

Sidebar

Related Questions

I have a service class in my Android app which uses a timer. The
I have an application which uses the tts engine in Android, now as the
I have an network application which uses a select loop like this: bool shutdown=false;
I have an Android App that uses a TabHost layout. Every tab calls the
Basically I have created a Blackjack app that uses several methods that get called
Is there any way in android to intercept activity method calls (just the standart
I'm trying to work out how to organize an android application that will have
I have an interesting problem and I was looking for a solution; Hoping that
i'm dooing this tutorial and at one point he uses the R.id.xxxx where x

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.