本文介绍了将字符串添加到Android的ImageView对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将一个String附加到ImageView对象中,以便可以执行imgView1.getString()
之类的操作,并且它将返回它.
I need to attach a String into the ImageView object so that I could do something like imgView1.getString()
and it would return it.
我知道有getTags
和setTags
,但是据我了解,它仅使用整数.
I know there is getTags
and setTags
but from my understanding that just uses ints.
谢谢
推荐答案
只需补充@dharms答案,就可以将任何Object
设置为ImageView
的标签,无论是int,double,String等.
Just complementing @dharms answer, you can set any Object
as the tag for the ImageView
, whether is an int, double, String, etc.
因此,您可以这样做:
imgView1.setTag("some_string")
然后取回它:
String someString = (String) imgView1.getTag();
这篇关于将字符串添加到Android的ImageView对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!