So currently, I am trying to create a selected state for three textviews
Currently, for each of the textviews ( H M S) the text is red:
However, when tap the H M or S I want it to turn another color--white.
So I tried to follow this:
Android - Textview change color on changing of state
and I did this (selected_text.xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:color="#ffd10011"/> <!-- selected -->
<item android:color="@color/red_highlight"/> <!-- default -->
</selector>
and applied that:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Hours"
android:textSize="30sp"
android:textColor="@color/selected_text"
android:id="@+id/hourtext"
android:layout_marginLeft="45dp"
android:layout_alignTop="@+id/minutetext"
android:layout_alignLeft="@+id/seekArc"
android:layout_alignStart="@+id/seekArc" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Minutes"
android:textSize="30dp"
android:textColor="@color/selected_text"
android:id="@+id/minutetext"
android:layout_below="@+id/seekArc"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Second"
android:textSize="30dp"
android:textColor="@color/selected_text"
android:id="@+id/secondtext"
android:layout_alignTop="@+id/minutetext"
android:layout_alignRight="@+id/seekArc"
android:layout_alignEnd="@+id/seekArc"
android:layout_marginRight="43dp" />
However, the textviews do not change color after I click on them.
How do I fix this?
Also, I was wondering if it is better to implement this in java code since I need to perform a different function after each textview is clicked/highlighted. If so, how can that be implemented?