user1050632
user1050632

Reputation: 668

TextView setText options

Trying to set a TextView, to a certain message containing a variable.

for Example

tvOddEven.setText("You have entered:", odd, "% of numbers");

odd is an int variable

it's giving me an error, that I can't use those parameters.

ideas?

Upvotes: 0

Views: 122

Answers (2)

PravinCG
PravinCG

Reputation: 7708

Try this:

tvOddEven.setText("You have entered:" + String.valueOf(odd) + "% of numbers");

Since odd is not a String you need to convert it to string.

Upvotes: 1

tvOddEven.setText("You have entered:" + odd + "% of numbers");

Upvotes: 5

Related Questions