I've set a tag on an imageview to be "blank", so it looks like this in the xml file
android:tag="blank"
Now when I run this
((String) buttons[button-2].getTag() == "blank"
It returns false. I can't find why, any ideas? Any help greatly appreciated.
Use:
((String) buttons[button-2].getTag().equals("blank")
For String
comparison you must use equals
, ==
tests references.
You can also intern
the String. This always produces the same object for the same string contents, so you can do comparisons with ==
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.