如果你有这样的 TextView +图像:
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableRight="@drawable/calendar" />
如何从 java 代码中的 textview 引用中获取 ImageView 引用? 我想为图像设置点击事件,而不是 TextView 。
有人知道吗?
谢谢。
最佳答案
textView.getCompoundDrawables()
将获取 drawableLeft
、drawableRight
、drawableTop
和 drawableBottom
项。和 setCompoundDrawables()
来设置它们。
关于java - 如何在 android 的复合绘图中获取 imageview 引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18662166/