5
我在textview.so的右侧有一个箭头图像,我使用的是android:drawableRight="@drawable/arrow"
,它工作正常。 但我希望当textview处于选定状态,那么我需要显示箭头图像否则不。 有什么办法可以通过选择器来实现它。是否可以给状态textdrawables textview?
有人可以告诉我,我该如何实现它?
我在textview.so的右侧有一个箭头图像,我使用的是android:drawableRight="@drawable/arrow"
,它工作正常。 但我希望当textview处于选定状态,那么我需要显示箭头图像否则不。 有什么办法可以通过选择器来实现它。是否可以给状态textdrawables textview?
有人可以告诉我,我该如何实现它?
引起以下异常。
如果您没有声明默认状态,那么选择器不适用于我。因此,我已经将一个透明图像置于默认状态,它适用于我。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image" android:state_pressed="true"></item>
<item android:drawable="@drawable/image" android:state_selected="true"></item>
<item android:drawable="@drawable/image" android:state_focused="true"></item>
<item android:drawable="@drawable/imagetrans"/>
</selector>
用法: -
<TextView
android:id="@+id/txtobject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:clickable="true"
android:drawableRight="@drawable/selector"
android:focusableInTouchMode="true"
android:text="@string/object"
android:textSize="25sp" />
亲爱straya,我曾尝试<项目机器人:可绘制= “@空”/>,但它造成上述exception.Your答案并没有为我工作,然后我如何接受这个答案?如果我接受这个答案,那么很多使用stackoverflow的人都会被我误导。 – Hitendra 2012-02-28 07:26:51
亲爱的straya,在这里我们要帮助我们的社区,所以我们的目标应该是帮助社区,而不仅仅是声誉得分。我感谢你的帮助,但它并不适合我。 – Hitendra 2012-02-28 07:30:17