Reputation:
I want to display a number text that increases if the statement is true and to show the number in a text view, the error comes when I change the text view text when the number is increased.
int stars = 0; //Global variable
//onClick{...}
public void changeTextViewToStarsNumber(){
if(editText.getText().equals("153"){
stars = stars + 10;
textView.setText(stars); //The error line
}
}
Upvotes: 0
Views: 52
Reputation: 179
.setText() needs a String value You need to convert your starts to a String type, by using valueOf() function.
Upvotes: 0
Reputation: 1767
Is your error at compilation? If so, then I am guessing you need to parse your stars
into a String.
textView.setText(String.valueOf(stars)); //The error line
Upvotes: 1