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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:09+00:00 2026-05-26T14:29:09+00:00

I have a ListView with SimpleCursorAdapter. The layout was using a LinearLayout, but when

  • 0

I have a ListView with SimpleCursorAdapter. The layout was using a LinearLayout, but when reading manuals about memory consumption for complex (nested) layouts, I switched to RelativeLayout instead and I’ve managed to setup the layout exactly as I want.

Now, there’s one quirk. In the emulator, I cannot click the list items. It seems as if the elements are one big “no button”. However, if I use the emulator arrows and select the listview element (highlights it) and click the button, it works fine.

Why can’t I “click” the listview items since I switched to RelativeLayout?

Here’s the XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" >

  <TextView
    android:id="@+id/locationName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Junk text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

  <TextView
    android:id="@+id/numStores"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/locationName"
    android:text="Junk text #1: 117"
    android:textSize="10dp" />

  <TextView
    android:id="@+id/numItems"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/numStores"
    android:text="Junk text #2: 42"
    android:textSize="10dp" />
</RelativeLayout>

I even tried android:clickable="true" for RelativeLayout, to no avail.

EDIT
Code for onClick is as follows:

listItems.setOnItemClickListener(new OnItemClickListener() {
  @Override
  public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    int countyID = cursor.getInt(cursor.getColumnIndex(LocationDB.C_ID));
    int numItems = cursor.getInt(cursor.getColumnIndex(LocationDB.C_NUM_ITEMS));
    int numStores = cursor.getInt(cursor.getColumnIndex(LocationDB.C_NUM_STORES));
    String countyName = cursor.getString(cursor.getColumnIndex(LocationDB.C_NAME));
    String foo = String.format(TAG + "Clicked ID #%d (%s), stores = %d, items = %d", countyID, countyName, numStores, numItems);
    Log.i(LOG_TAG, foo);

    // Show the item in a new activity
    Intent apan = new Intent(avBase, Browser.class);
    apan.putExtra("countyID", countyID);
    startActivity(apan);
  }
});

EDIT 2

The code is now tested on my phone, and I get the same error; can’t click the items when using RelativeLayout.

  • 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-26T14:29:10+00:00Added an answer on May 26, 2026 at 2:29 pm

    I faced some issues with this, too, which seemed to be related to the combination of the ListView‘s on click listeners and those I assigned each individual item in my Adapter.

    In my Adapter.getView() I had to make sure the items were configured like:

    item.setLongClickable( false );
    item.setClickable( false );
    item.setOnClickListener( null ); 
    

    while my ListView had to have its OnItemClickListener and/or its OnItemLongClickListener set.

    Turning on clicks on the individual items and on the listview would not work. Maybe that’s what’s causing your issue, too.

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

Sidebar

Related Questions

I have learned that when using android:entries with a ListView , it uses android.R.layout.simple_list_item_1
I have a ListView with a custom item layout backed by a SimpleCursorAdapter. I'd
I have a ListView control that is in FullRowSelect mode, MultiSelect off and using
I have a listview which is populated by a SimpleCursorAdapter that is binding data
I have Listview on WinForm I need to have two columns but without headers,
I am filling in my listview with a SimpleCursorAdapter . By using getView() I
I have this SimpleCursorAdapter for my ListView, the view is set from NewView. I'm
I have a ListView (set to CHOICE_MODE_SINGLE) I have a SimpleCursorAdapter who fill my
I have a ListView on each row i have a LinearLayout with some objects
I have a ListView which is populated by a SQLite query in OnCreate using

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.