Lets say I want a textview to display 5.
I assume I can use TextView.setText(5).
But in the above case, the compiler would be looking for a resource id 5 and not the integer 5.
What should I do if I really want to display the "integer" ?.
Lets say I want a textview to display 5.
I assume I can use TextView.setText(5).
But in the above case, the compiler would be looking for a resource id 5 and not the integer 5.
What should I do if I really want to display the "integer" ?.
You need to cast it to String (now compiler won't it interpret as resource):
TextView.setText(5 + "").
TextView.setText(String.valueOf(5));
TextView.setText(Integer.toString(5));
Well, you actually have 5 (five) choices, but the first 2 are the most common.
1) txtTextView.setText(String.valueOf(5)) // or Integers's equivalent
2) textTextView.setText(R.string.value_of_5) // this would be an int value declared in strings.xml