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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:08:35+00:00 2026-05-26T11:08:35+00:00

I’m creating a ListView with buttons and having some issues. My activity need to

  • 0

I’m creating a ListView with buttons and having some issues.
My activity need to do 2 different actions for each action (ItemClick and buttonClick).

I assumed that:

1 – Because I has button on list items, I cant use OnItemClickListener(). Right?

So, I create layout for list items and make it clickable.

listitem_textview_button.xml:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:background="@drawable/selector_list_item">

<Button 
    android:id="@+id/listitem_textview_button_btn"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:text="@string/edit" />

<TextView
    android:id="@+id/listitem_textview_button_txv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:textSize="14sp"
    android:textColor="@drawable/selector_textview"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:layout_toRightOf="@+id/listitem_single_line_w_button_btn" />

</RelativeLayout>

Notice that I’ve created a selector for the layout and a stateColorList for Textview.

selector_list_item.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_window_focused="false"
        android:drawable="@color/transparent" />

    <item 
        android:state_focused="true" 
        android:state_enabled="false"
        android:state_pressed="true"
        android:drawable="@drawable/shape_list_item_disabled" />

    <item 
        android:state_focused="true" 
        android:state_enabled="false"
        android:drawable="@drawable/shape_list_item_disabled" />

    <item 
        android:state_focused="true" 
        android:state_pressed="true"
        android:drawable="@drawable/shape_list_item_transition" />

    <item
        android:state_focused="false" 
        android:state_pressed="true"
        android:drawable="@drawable/shape_list_item_transition" />

    <item 
        android:state_focused="true"
        android:drawable="@drawable/shape_list_item_focus" />
</selector>

selector_textview.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:state_selected="true" android:color="@color/black" />
   <item android:state_focused="true" android:color="@color/black" />
   <item android:state_pressed="true" android:color="@color/black" />
   <item android:color="@color/red" />
</selector>

2 – This is the best way to implement a ListView with custom items (included TextView Colors)?

The above code does not change the color of textViews when I click on items.

In some tests I saw that the text color changes when:
1. Using arrows of emulator.
2. Removing the button of ListView item.

Where is the problem?

prinscreens:
listitem selected by arrow device (text black, ok!)

listitem selected by emulator arrow

listitem clicked by finger (text red, should be black, fail)

listitem clicked by finger(using device)

answer:

add android:duplicateParentState="true" to TextView.

  • 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-26T11:08:36+00:00Added an answer on May 26, 2026 at 11:08 am

    I don’t get it, your layout is clickable but you have buttons? Is the button for selecting a row?

    If I were you I would not make anything clickable except the button. android:focusable=”false” android:clickable=”false”

    Then you can in the button listener set the selection on a row manually:

    getListView().setSelection(position);
    

    Let me know if this works.

    [EDIT] The real problem is that the TextView needs to be clickable, not the layout.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.