android.content.res.Resources$NotFoundException: String resource ID #0x1
2016-11-01 10:30
344 查看
之前忘了记录这个错误,今天又遇到了。唉,人不能纵容自己犯懒,遂记录之。
错误:android.content.res.Resources$NotFoundException: String resource ID #0x1
原因:一般发生在参数 int resId 错误,你把String赋值给int的resId,所以编译器找不到正确的resource于是报错。
最简单的例子,检查一下你的Toast.makeText()啊textView.setText啊之类的函数,这种函数通常有几个重载,如:
textView.setText(CharSequence text);
textView.setText(int resId);
......
如果不小心将一个int值传给了它,那它不会显示该int值,而是跑到工程下去找一个对应的resource的id,当然是找不到的,于是就报错啦。
解决办法:
如果要显示该int值,就要将int转化成String或者CharSequence,百度上很多办法。
个人比较喜欢这么干:在该int值后面+"",强制转为String。简单易用。╮(╯_╰)╭
错误:android.content.res.Resources$NotFoundException: String resource ID #0x1
原因:一般发生在参数 int resId 错误,你把String赋值给int的resId,所以编译器找不到正确的resource于是报错。
最简单的例子,检查一下你的Toast.makeText()啊textView.setText啊之类的函数,这种函数通常有几个重载,如:
textView.setText(CharSequence text);
textView.setText(int resId);
......
如果不小心将一个int值传给了它,那它不会显示该int值,而是跑到工程下去找一个对应的resource的id,当然是找不到的,于是就报错啦。
解决办法:
如果要显示该int值,就要将int转化成String或者CharSequence,百度上很多办法。
个人比较喜欢这么干:在该int值后面+"",强制转为String。简单易用。╮(╯_╰)╭
相关文章推荐
- android.content.res.Resources$NotFoundException 异常处理
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException: String resource ID #0x6错误的解决办法
- android.content.res.Resources$NotFoundException: String resource ID #0x7f050016
- android.content.res.Resources$NotFoundException: Resource ID解决办法
- android.content.res.Resources$NotFoundException: Resource ID #0x7f030010
- android.content.res.Resources$NotFoundException异常处理
- 解决android.content.res.Resources NotFoundException的一个方法
- 解决android.content.res.Resources NotFoundException的一个方法
- Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0
- android.content.res.Resources$NotFoundException: String resource ID #0x8错误
- android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedVa
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- android.content.res.Resources$NotFoundException:String resource ID #0x86
- 关于Android中android.content.res.Resources$NotFoundException: String resource ID #0x9这类问题的解决
- android.content.res.Resources$NotFoundException
- android.content.res.Resources$NotFoundException解决方案
- android.content.res.Resources$NotFoundException: String resource ID #0x6d
- android.content.res.Resources$NotFoundException错误的解决办法
- android.content.res.Resources NotFoundException