问题
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