Saturday, October 29, 2011

Displaying an integer in a TextView on Android

This one took me for a ride for a few hours.  I went all over the internet with little help.  Here is the problem.  I have a layout created with TextView, but I want to display an integer value in that field. 

 

I declare my integer as:

int score = 1;

I also have a string value called scoreText.

I have a TextView with an ID of score.  Here is how I display the integer in the TextView

TextView text = (TextView)findViewById(R.id.score);

text.setText(scoreText.valueOf(score));

No comments:

Post a Comment