Thursday, August 18, 2011

android.content.res.Resources$NotFoundException:

Resources NotFoundException

 The below Resources$NotFoundException log results from user error and is easily fixed.

 ERROR/AndroidRuntime(9202): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
08-18 12:32:14.057:
ERROR/AndroidRuntime(9202):   at android.content.res.Resources.getText(Resources.java:201)
08-18 12:32:14.057:
 ERROR/AndroidRuntime(9202):  at android.widget.TextView.setText(TextView.java:2853)

 

I get this error when I am trying to set a View’s text using an integer value like:

 text.setText(SomeInteger) // This is incorrect !

Instead, to set the text of a view using an integer, you need to do:
text.setText(Integer.toString(SomeInteger)) // setText with an int
The problem is that setText(int) is reserved for string resource ids, like:
view.setText(R.string.someStringId) // setText with a string resource id

 

 

2 comments:

  1. ah! you are a genius!!
    Thanks

    ReplyDelete
  2. It can also be very simply without using toString method like this one
    text.setText("someString" + someInteger);

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...