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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:46:35+00:00 2026-05-16T16:46:35+00:00

I have a textview, I set it as clickable and focusable – how do

  • 0

I have a textview, I set it as clickable and focusable – how do I get it to highlight to orange (like a button) when the user focuses it with the trackwheel etc?:

TextView tv = ...;
tv.setClickable(true);
tv.setFocusable(true);

Thanks

  • 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-16T16:46:35+00:00Added an answer on May 16, 2026 at 4:46 pm

    This is quite easy. Here is the solution.

    You have an TextView element with its background attribute set to @drawable/tbselector like this.

    <TextView android:text="My text" 
        android:id="@+id/tv01"
        android:layout_width="300dip"
        android:layout_height="150dip"
        android:layout_gravity="center_horizontal"  
        android:background="@drawable/tbselector"/>
    

    The last attribute android:background is essential the other stuff is up to you.

    Now you create a tbselector.xml in your drawable subdirectory. Which looks like this.

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

    Now you create a bgdefault.xml in your drawable subdirectory which looks like this.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <size
            android:width="200dip"
            android:height="150dip"
            android:color="#00FF00"/>
        <solid
            android:color="#00FF00"/>
    </shape>
    

    Finally create a bgselected.xml in your drawable subdirectory which looks like the other one with other color values like this for example.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <size
            android:width="200dip"
            android:height="150dip"
            android:color="#FFFF00"/>
        <solid
            android:color="#FFFF00"/>
    </shape>
    

    And thats it you now have a state dependent TextView background. You can however decide to set your drawables in your selector XML it’s totally up to you. My values are just random values to show you the difference.

    Hope it helps.

    • 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 button myButton to TextView. How to get it in
I am trying to make my TextView clickable. I have set setMovementMethod() with LinkMovementMethod.
I have a TextView in my layout which has an attribute clickable=true set in
I have set linearlayer to become clickable and want it to act like a
I have an empty TextView set for my ListView . When there is no
I have a TextView which i set the text using setText(). In properties, I
I have defined the TextView array as final. And I set a OnClickListener() for
I have a question. How Can I set font for example: Harrington in textview.
I have a textView and text like This is the Simple Text with KeyWord
I have a textview that has a fill_parent width and a set height. Is

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.