How can I display an Integer value in TextView?
When I try, I get an error android.content.res.Resources$NotFoundException: String resource ID
If you need to set an integer value, use tv. setText("" + 5) as setText() is an overloaded method that can handle string and int arguments. To get a value from tv use tv. getText() .
There are two methods of changing the color of a TextView and the code for that has been given in both Java and Kotlin Programming Language for Android, so it can be done by directly adding a color attribute in the XML code or we can change it through the MainActivity File.
A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing.
TextView tv = new TextView(this); tv.setText(String.valueOf(number));
or
tv.setText(""+number);
TextView tv = new TextView(this); tv.setText("" + 4);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With