Add String to ImageView Object Android

女生的网名这么多〃 提交于 2019-12-23 22:00:51

问题


I need to attach a String into the ImageView object so that I could do something like imgView1.getString() and it would return it.

I know there is getTags and setTags but from my understanding that just uses ints.

Thank you


回答1:


Just complementing @dharms answer, you can set any Object as the tag for the ImageView, whether is an int, double, String, etc.

So in your case you can do this:

imgView1.setTag("some_string")

and then to retrieve it just do:

String someString = (String) imgView1.getTag();



来源:https://stackoverflow.com/questions/36438086/add-string-to-imageview-object-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!