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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:09:34+00:00 2026-06-15T01:09:34+00:00

There is a TextView in every ListView Item which I am setting through custom

  • 0

There is a TextView in every ListView Item which I am setting through custom adapter. The TextView XML is not in same file where a ListView XML has been written, I want that when any Item of ListView gets selected the font color of that particular item should change. I also tried this by defining the different states of TextView i.e selected, focused and pressed but that dose not solve my problem. Please suggest me some solutions for it. Here is snippet..

a listeview in one xml file for eg. file1.xml

<ListView
    android:id="@+id/listView1"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="0.5"
    android:clickable="true" />

and a TextView in different xml.. i.e file2.xml

<TextView
    android:id="@+id/rowListTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="10dp"
    android:paddingTop="10dp"
    android:text="@string/app_name"
    android:textColor="@color/file3"
    android:textSize="10sp"
    android:textStyle="bold" />  

file for text color attribute in res/color folder i.e file3.xml.

<item android:state_selected="true" android:color="@android:color/white"/>
<item android:state_focused="true"  android:color="@android:color/white"/>
<item android:state_pressed="true"  android:color="@android:color/white"/>
<item android:color="@android:color/black"/>

  • 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-06-15T01:09:36+00:00Added an answer on June 15, 2026 at 1:09 am

    Below snippet will help you.

    listView.setOnItemClickListener(new OnItemClickListener() {
    
        @Override
        public void onItemClick(AdapterView <? > adapterView, View rowView,
        int position, long id) {
            TextView textView = (TextView) rowView.findViewById(R.id.rowListTextView);
    
            textView.setTextColor("Desired Color");
    
        }
    });
    

    I have not included scenario like retaining text color when you scroll the list and your selected item goes out of focus. This snippet will guide you in the right direction.

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

Sidebar

Related Questions

I have a custom ListView in which there are 2 buttons and a textview
In my project there is a listview which contains textview and checkbox..Here is my
I have a listView (vertical) and every list item has a horizontal list view
Is there any simple way how to draw obliquely strike through on TextView? Now
Is there any way to copy text from a TextView that has User Interaction
I have an empty TextView set for my ListView . When there is no
I'm setting a TextView with the id @android:id/empty to display a message when there
I've a ListView where every element in the list contains a TextView and two
I created a ListView with a custom array adapter of MyObject . One instance
I've a ListView where every element in the list contains a TextView and two

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.