Reputation: 875
Hell i am trying to compare textview value with button how can i do it?
i tried this way but not working.
button xml - android:tag = "1"
Java
Button btn = (Button) findViewById(id);
string valu = btn.getTag();
string txt = textView.getText();
if(txt.equals(valu))
{
// do what you want
}
Upvotes: 0
Views: 493
Reputation: 18933
Simply use this.
if (b.getTag().toString().equalsIgnoreCase(tv.getText().toString())) {
Toast.makeText(getApplicationContext(), "HI", 9000).show();
}
Upvotes: 1
Reputation: 12523
try this:
textView.getText().toString();
getText()
returns a CharSequence
not a String
.
Because of that your equals
must be false.
Upvotes: 1