Frage

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.

War es hilfreich?

Lösung

Use:

((String) buttons[button-2].getTag().equals("blank")

For String comparison you must use equals, == tests references.

Andere Tipps

You can also intern the String. This always produces the same object for the same string contents, so you can do comparisons with ==.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top