android.content.res.Resources$NotFoundException: String resource ID #0x1异常
来源:互联网 发布:java正则匹配汉字 编辑:程序博客网 时间:2024/05/16 23:40
错误: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。简单易用。╮(╯_╰)╭
当然最好的是String.valueof();
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
- 2015年7月17日 午後3時のニュース NHK新闻稿
- codeforces558C Amr and Chemistry
- 算法导论,最优钢条切分
- (算法入门)基本图论-广度优先搜索之JAVA实现
- codevs1032
- android.content.res.Resources$NotFoundException: String resource ID #0x1异常
- JQuery easyUI combobox 数据过滤(filter)
- 黑马程序员——Java基础---网络编程
- UVA 232 Crossword Answers
- 砝码称重:动态规划与母函数方法
- 爬虫抓取时的几个小细节-缓存、编码、解析
- Java方法参数- 值调用的理解
- IEEE802帧和EthernetII帧的封装格式对比
- [Effective Java]第八章 通用程序设计