android.content.res.Resources$NotFoundException: String resource ID #0x1
来源:互联网 发布:天界五行进化数据 编辑:程序博客网 时间:2024/05/22 00:45
之前忘了记录这个错误,今天又遇到了。唉,人不能纵容自己犯懒,遂记录之。
错误: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。简单易用。╮(╯_╰)╭
0 0
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException:+String+resource+ID+#0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- [Android] 快速实现一个可切换Tab标签页的组件
- UVALive 4260 Fortune Card Game (Regionals 2008 Asia Taipei +DP)
- 继戴尔670亿收购EMC后,科技界钱多的让人窒息的五大收购案
- 《剑指Offer》面试题:约瑟夫环问题
- population & sample covariance, standard deviation Aggregate in PostgreSQL
- android.content.res.Resources$NotFoundException: String resource ID #0x1
- 用PostgreSQL了解一些统计学术语以及计算方法和表示方法 - 1
- ActionBarDrawerToggle is Deprecated
- 解决Android Studio的adb not response。。。错误
- 第七周-项目5 -排队看病模拟
- Masonry介绍与使用实践:快速上手Autolayout
- Hadoop2.x.x伪分布式环境搭建、测试
- 论set和map
- javassist 初步学习