In Android a very common error you can get is Resources Not Found Exception, has you can see below:
Uncaught handler: thread main exiting due to uncaught exception android.content.res.Resources$NotFoundException: String resource ID #0x1 at android.content.res.Resources.getText(Resources.java:205) at android.widget.TextView.setText(TextView.java:2809)
This happens when you try to set a View’s text with a integer value, yes the .setText(int) function exists, but it is reserved for string resource ids only, the ones you set in strings.xml in values, for example: R.string.myStringId
This is why the setText(int) function exists:
myView.setText(R.string.myStringId); //this works
But if you’re doing something like
myView.setText(someInt); // this is wrong!!
You will get this error, if you really want to write someInt in the view’s text, you will need to do this:
myView.setText(Integer.toString(someInt)); //this works
And if you want to write a text concatenating a string with a resource id of another string?
Well, in that case you use the .getString(int) function, like so:
myView.setText("Some Text: " + getString(R.string.myStringId));