I wanted a clickable TextView that changes color and holds it, that changes previously changed text back to default color. And of course I wanted some state to be changed when each TextView was “checked.” Basically a TextView that acts like a RadioButton, or a RadioButton minus the button.
At first I tried to come at from the TextView angle. But it seems like using RadioButtons and adding text behavior is easier since RadioButtons extend TextView anyway.
So I have this color resource applied to each RadioButton:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:color="#0000ff" />
<item android:state_focused="true" android:state_pressed="true" android:color="#0000ff" />
<item android:state_focused="false" android:state_pressed="true" android:color="#0000ff" />
<item android:state_checked="true" android:color="#0000ff" />
<item android:color="#ff00ff00" />
</selector>
That gets me the text behavior I want. Now I just need a way to hide the RadioButton itself. Ideally this would be in XML so I can just apply a style to various RadioButton, but I’m not going to turn my nose up at a RadioButton extension.
So, anybody know how to hide the RadioButton button itself?
You should use
CheckedTextView. It supportscheckedstate.OR
You can use
RadioButtonand set its button tonull: