Integer value in TextView


Question

How can I display an Integer value in TextView?

When I try, I get an error android.content.res.Resources$NotFoundException: String resource ID

1
38
7/3/2017 9:40:00 PM

Accepted Answer

TextView tv = new TextView(this);
tv.setText("" + 4);

39
10/22/2010 6:10:33 AM

TextView tv = new TextView(this);
tv.setText(String.valueOf(number));

or

tv.setText(""+number);

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon