This is my TextView
<TextView
android:id="@+id/home_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Home"
android:textColor="@drawable/color_state"/>
This is my color_state.xml
code in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="false"
android:color="#fff"/>
<item
android:state_pressed="true"
android:state_selected="true"
android:color="#ff0000"/>
</selector>
I have searched similar questions but what I want is a different thing, all the questions which stack suggested "possible duplicate of", I already tried but that is not what I want, that's why I asked this question with all the explanation that I need.Existing question only changes the color when TexttView
is clicked
I have two TextView in a LinearLayout
, I just want to change the color of my text when I click on it, with this code I can change color but when I release click the color goes back to the original.All I want is to change the color when I click on TextView and the change should be permanent until another view is not clicked
Please any help will be appreciated