I'm having troubles with an if
statement to do something if the current string in a TextView
is "Heads."
This is my current code:
if (myCoin = "Heads") {
ImageView img = (ImageView) findViewById(R.id.imageView);
img.setImageResource(R.mipmap.heads);
}
"myCoin" is the name of a string that contains the words "Heads" and "Tails."
final String[] myCoin= {"Heads", "Tails"};
When a random number is generated, the TextView
displays one of those words depending on the number. However, I am not able to run the code due to the squiggly red-line under (myCoin = "Heads")
that reads:
Incompatible Types.
Required: Java.Lang.String[]
Found: Java.Lang.String
As you can see, my string DOES have the square brackets, so I'm wondering if I can even use myCoin
in an if
statement.
SOLVED