android错误之android.content.res.Resources$NotFoundException:
来源:互联网 发布:华讯网络待遇 编辑:程序博客网 时间:2024/06/05 18:10
问题一、
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
如果遇到这个问题,首先考虑以下原因:
你是否在setText()方法中设置了一个int型变量,比如setText(10)。
这样Android系统就会主动去资源文件当中寻找, 但是它不是一个资源文件ID, 所以就会报出这个bug。
解决办法:将int型业务数据,转换成String类型即可,比如setText(10+“”);
问题二、Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
错误: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,当然是找不到的,于是就报错啦。
比如我这里是这样的:
- count.setText(incall.getCount());
incall.getCount();返回的是一个int值,直接setText肯定不行啊,就是上面的错误类型,
解决办法就是
- count.setText(String.valueOf(incall.getCount()));
或者
- count.setText(incall.getCount() + "");
0 0
- Android错误android.content.res.Resources$NotFoundException:
- android错误android.content.res.Resources$NotFoundException
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException:
- android错误之android.content.res.Resources$NotFoundException:
- 关于错误 android.content.res.Resources$NotFoundException
- android.content.res.Resources$NotFoundException错误处理
- 【错误反思】 android.content.res.Resources$NotFoundException
- 错误:android.content.res.Resources$NotFoundException
- 错误:android.content.res.Resources$NotFoundException
- android.content.res.Resources$NotFoundException
- android.content.res.Resources NotFoundException
- android.content.res.Resources$NotFoundException
- 腾讯微信技术架构
- Android XML设置圆角边框
- OS X 和 iOS 中的多线程技术
- 网站安全性之js注入
- Linux之Makefile(origin)
- android错误之android.content.res.Resources$NotFoundException:
- ubuntu下mysql的安装以及基本命令
- 1亿qq在线背后的技术
- unity3d接口
- 进程通信学习笔记(读写锁)
- linux 及mysql常用命令
- 《数据结构》实验五:树和二叉树 实验(实验报告)
- 如何查看CPU是否支持虚拟化
- 海量数据问题和解决方案搜集汇总