Monday, 9 February 2015

Can I compare a TextView's xml text with another string programmatically?



If I set the text of a TextView in XML, like this:



<TextView
...
android:text="0" />


Can I compare that string in Java? Doing this:



private void InitializeMethod() {
A_1 = tv_1.getText().toString();
}

private void CheckAnsMethod() {
if (A_1 == "0"){
correctAns.start();
}
}else{
wrongAns.start();
}
}


causes the sound 'wrongAns.mp3' to be played...


No comments:

Post a Comment