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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:39:55+00:00 2026-06-04T18:39:55+00:00

I have some textViews in my LinearLayout. They are clickable and I would like

  • 0

I have some textViews in my LinearLayout.
They are clickable and I would like to make them onClick like for a ListView.
For the listView, when the user clicks an item, the background becomes green I think.

I know that i can do this manually with

tv.SetBackgroundColor(Color.GREEN);

But is there something automaticaly to do this, like for the listView where the selection is managed automaticaly.

Thank you.

  • 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-04T18:39:56+00:00Added an answer on June 4, 2026 at 6:39 pm

    You need to define the background as a new XML file containing a list of states.

    http://developer.android.com/guide/topics/resources/color-list-resource.html

    For example, create a file called background_states.xml in your drawable folder and write something like this:

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

    Then define this new file as background in your TextView:

    <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="@drawable/background_states"
    

    See the link above for more information about the different states.

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

Sidebar

Related Questions

I would like to add programmatically to LinearLayout some TextViews . And I want
I have listview item like below <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=60dp android:orientation=horizontal android:descendantFocusability=blocksDescendants > <TextView
I have a layout which contains some views like this: <LinearLayout> <TextView...> <TextView...> <ImageView
I have a ListView on each row i have a LinearLayout with some objects
I have a layout, which include some TextViews and ImageViews. Haven't they created an
I have a LinearLayout with some nested LinearLayouts, ImageView's and TextViews. One of the
I have a ListView and TextView. They are both in a LinearLayout . And
I have a fairly simple layout with an image, and some textviews wrapped in
I have some files that are uuencoded, and I need to decode them, using
I have some XML which contains records and sub records, like this: <data> <record

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.