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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:31:43+00:00 2026-05-25T00:31:43+00:00

I have a customized ListView that each row of the list is composed by

  • 0

I have a customized ListView that each row of the list is composed by an ImageView and two TextView‘s. I want to change the text’s color to white when a list’s item is clicked (only in the clicked item). Also, I want to change back the color to black when the item is “unclicked” (when the “press” is released). I already made the item’s background color change when it was clicked with the following list_item_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item 
    android:state_selected="false"
    android:state_pressed="false" 
    android:drawable="@color/white" />

<item android:state_pressed="true" 
    android:drawable="@color/red_destaques" />

<item android:state_selected="true"
    android:drawable="@color/red_destaques" />
</selector>

And the listitem_row.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="50dip"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="5dip"
    android:maxHeight="50dip"
    android:adjustViewBounds="true"
    android:background="@color/list_item_bg">

    <ImageView
        android:layout_width="70dip"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:adjustViewBounds="true"
        android:scaleType="fitStart" 
        android:src="@drawable/imagem_padrao_lista" 
        android:id="@+id/listItemLogo">
    </ImageView>

    <TextView
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_height="wrap_content"
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_toRightOf="@+id/listItemLogo"
        android:layout_toLeftOf="@+id/listItemArrow"
        android:textColor="#000000"
        android:layout_marginLeft="5dip"
        android:adjustViewBounds="true" 
        android:id="@+id/listItemTitle">
    </TextView>

    <TextView
        android:layout_height="wrap_content"
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_toRightOf="@+id/listItemLogo"
        android:layout_below="@+id/listItemTitle"
        android:textColor="#333333"
        android:layout_marginLeft="5dip"
        android:adjustViewBounds="true" 
        android:id="@+id/listItemDescription">
    </TextView>
    <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/setinha_navegacao" android:layout_centerVertical="true" android:id="@+id/listItemArrow"></ImageView>

</RelativeLayout>

I the text to change it’s color exactly in the same manner that the background changes as shown in the above xmls. I would prefer doing this change by code if possible…

  • 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-25T00:31:44+00:00Added an answer on May 25, 2026 at 12:31 am

    Create a new StateListDrawable like you did before but with black as default color and white when pressed.

    <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/white" />
    </selector>
    

    Now for in the TextView change the text color to the new drawable:

    android:textColor="@color/list_item_text"
    

    More on StateListDrawables: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

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

Sidebar

Related Questions

I have listview having customized some textview and one imageview. When I long click
I have a ListView, and I want to customize the layout of each item
I have used a customized list view in which i have added 4 TextView
I have a customized ListView like this: List<Journal_Database> values = localDatabase.getAllJournalNames(); ListView journalNames =
I have a ListView, and I want that when I press an item, go
I have a ListView that uses a customized adapter, but I can't click on
I am creating a customized listview header that has the header text but also
I have a customized listview. In this list, I have something like 15 items.
I have a custom list view which contains two text views and on button.
I have a listview which is customized to display an image and 2 textview.

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.