Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
来源:互联网 发布:淘宝商城秋冬服饰团购 编辑:程序博客网 时间:2024/05/22 10:52
错误提示: Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
原因:一般发生在参数 int resId 错误,你把String赋值给int的resId,所以编译器找不到正确的resource于是报错,一般情况下在这一句提示的后面就有指出具体在哪一行了 ,然后你直接去改就行了。
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1 at android.content.res.Resources.getText(Resources.java:244) at android.widget.TextView.setText(TextView.java:3888) at com.wlj.utilstext.MainActivity.onCreate(MainActivity.java:29)
看上面报错中哪些代码是你自己写的 ,很明显我的是29行.
解决办法
最简单的例子,检查一下你的Toast.makeText()啊textView.setText啊之类的函数,这种函数通常有几个重载,如:
textView.setText(CharSequence text);
textView.setText(int resId);
……
如果不小心将一个int值传给了它,那它不会显示该int值,而是跑到工程下去找一个对应的resource的id,当然是找不到的,于是就报错啦。
比如我这里是这样的:
int versionCode = AppUtils.getVersionCode(this);tv3.setText(versionCode);
AppUtils.getVersionCode(this);返回的是一个int值,直接setText肯定不行啊,就是上面的错误类型,
解决办法就是
tv3.setText(String.valueOf(versionCode));
或者
tv3.setText(versionCode + "");
0 0
- Caused by: 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
- KEIL生成bin文件
- 练习20——函数和文件
- Java---三种文件拷贝的实现方法
- 完整的申请邓白氏编码的流程(手把手教你申请邓白氏编码)
- Linux下启动Oracle服务和监听程序
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
- union 与union all的区别
- 根据两点经纬度计算距离
- 消息队列设计精要
- mybatis中的#{}和${}的区别
- JZOJ 3453【NOIP2013中秋节模拟】连通块
- 修改数据表
- Maven多模块布局实例详解
- Layer3 OSPF的状态信息LSA3、4、5