Caused by: android.content.res.Resources$NotFoundException
来源:互联网 发布:2017好看的网络电影 编辑:程序博客网 时间:2024/05/17 00:56
撸代码时遇到如下错误
具体错误: Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
错误产生地方:
public void initData() { //获取当前版本和最新版本,并显示 nowtextVersion.setText(getAPPVersionCodeFromAPP(UpateActivity.this)); upatetexVersion.setText(newApVersion); }
错误原因:为什么会产生这样的错误呢?TextView.setText()中传入的值是应该是String类型,而在代码里我传入的是int类型,所以编译器找不到正确的Resources,于是报错。
解决方法:在TextView.setText()中传入String类型的值,将int值转化为String类型,这样上面的代码则可以改为:
public void initData() { //获取当前版本和最新版本,并显示 nowtextVersion.setText(getAPPVersionCodeFromAPP(""+UpateActivity.this));upatetexVersion.setText(""+newApVersion); }
好了,这样就可以了。总结一下,就是在撸代码的时候没有注意TextView.setText()传入的是String类型。想想也是尴尬,也体现出自身对基础的掌握不牢固,在撸代码时没有注意某些细节问题,导致出现不应该出现的错误。
阅读全文
0 1
- Caused by: android.content.res.Resources$NotFoundException
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable/***
- Caused by: android.content.res.Resources$NotFoundException: String array resource
- android错误之 Caused by: android.content.res.Resources$NotFoundException: File res/anim/snailanim.xml f
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable-mdpi/
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable/main_tab_conversation_
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml fr
- Android报Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0 .解决办法
- Android报Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0 .解决办法
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x**
- Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or pat
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x19
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x3
- 线程和进程
- Linux 的 IO 隔离
- 基于MFC输入输出位置设置方法
- Java学习笔记03——Java面向对象和语言进阶
- 开灯问题C++版
- Caused by: android.content.res.Resources$NotFoundException
- 关于回调函数的简单理解
- 创业日志(十四) 年中调整
- 超详细讲解Sqoop2部署过程
- 矩阵的掩膜操作实现图像对比度调整
- c++ 字符串顺时针挪几位
- 【Java进阶之网络编程】代码库(三)
- 以表格形式存到手机db数据库
- javascript:history.go()和History.back()的区别