+-

我想要一个可点击的TextView,它可以改变颜色并保持它,将以前更改的文本更改回默认颜色.当然,我希望在每个TextView被“检查”时更改一些状态.基本上是一个TextView,就像一个RadioButton,或一个RadioButton减去按钮.
起初我试图从TextView角度来看.但似乎使用RadioButtons并添加文本行为更容易,因为无论如何RadioButtons扩展TextView.
所以我将这个颜色资源应用于每个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>
这让我得到了我想要的文字行为.现在我只需要隐藏RadioButton本身的方法.理想情况下,这将是XML格式,因此我可以将样式应用于各种RadioButton,但我不会在RadioButton扩展名上嗤之以鼻.
那么,有谁知道如何隐藏RadioButton按钮本身?
最佳答案
您应该使用CheckedTextView.它支持检查状态.
要么
您可以使用RadioButton并将其按钮设置为null:
<RadioButton
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/selector"
android:button="@null"
android:paddingLeft="0dip"/>
点击查看更多相关文章
转载注明原文:android – 使用RadioButton / RadioGroup行为创建TextView(或反之亦然) - 乐贴网