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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:37:46+00:00 2026-05-26T19:37:46+00:00

I have a listView with custom rows containing buttons and I populate the listView

  • 0

I have a listView with custom rows containing buttons and I populate the listView with a custom cursorAdapter. I have set a selector for the button to change the background of it when pressed and it works great when I press on the button. The problem is it also works when I press anywhere else on the row.

I tried to set the parent view’s .setPressed, .setSelected, .setFocusable, .setFocusableInTouchMode, .setClickable attributes to false but it did not work.

I also tried to set button’s .setDuplicateParentStateEnabled to false but it did not help either.

If you can help me I will be grateful,

Thank you in advance

Let me extend my question: I have the rows without the button (which is the TextView with id of “delete_button” in xml code below) first. When I click another button in the view, the delete buttons slide into the rows and the background of the other TextView (id:list_title_text) changes to a constant color (because I don’t want it to be clickable anymore)

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/title_rows_relativelayout"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView
        android:id="@+id/list_title_text"
        android:layout_alignParentLeft="true"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textSize="25dp"
        android:textColor="@android:color/white"
        android:layout_alignParentRight="true"
        android:background="@drawable/selector_for_list_rows"
        android:paddingLeft="15dp"
        android:paddingBottom="5dp"
        android:paddingRight="15dp"
        android:gravity="center_vertical"
        android:typeface="normal" />
    </TextView>
    <TextView 
    android:id="@+id/delete_button"
    android:background="@drawable/selector_for_delete_button"
    android:layout_width="wrap_content" 
    android:layout_height="40dp"
    android:textSize="23dp"
    android:textColor="@android:color/white"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:gravity="center"
    android:layout_alignTop="@+id/row_icon_background" 
    android:layout_alignParentRight="true"
    android:layout_marginRight="5dp">
    </TextView>
 </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-26T19:37:47+00:00Added an answer on May 26, 2026 at 7:37 pm

    I solved this by setting the button’s setFocusable attribute to true inside my custom ListAdapter (I changed my CursorAdapter to ListAdapter after I wrote the question but I am sure it will work with CursorAdapter too). Now the button background changes only when I click on the button and nothing happens when I click anywhere else.

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

Sidebar

Related Questions

i have a listview with checkbox in each rows. i'm using custom cursoradapter and
I have a ListView with a custom Adapter that creates rows containing TextViews that
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I currently have a custom listview with two rows of text in each item,
I have a custom listView with a textView, editText and a Button on a
What I have: I have a ListView with custom rows, having a CheckBox &
i got the following problem. i have a ListView with custom rows consisting of
I have a custom listview which changes size when one of the rows is
I have a ListView which uses a custom adapter to display rows of data.
I have a listView with custom objects defined by the xml-layout below. I want

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.