Android错误:W/ResourceType(2411): No package identifier when getting value for resource number 0x
报错信息:
07-04 11:14:43.064: W/ResourceType(2411): No package identifier when getting value for resource number 0x0000001c
07-04 11:14:43.064: W/System.err(2411): android.content.res.Resources$NotFoundException: String resource ID #0x1c
错误位置示例代码:
int percent = current * 100 / total;
textView1.setText(percent);
原因分析:
主要原因是TextView的setText方法把传入的int类型的percent当做资源Id到项目中查询资源,而资源中却找不到相应的数值,就会报NotFoundException的错误。
在Android中利用id来索引资源的地方很多(如:Toast.makeText()等),所以如果不小心往方法中传入int类型的参数,虽然编译时IDE不会报错,但是运行时,很容易因找不到对应的资源而报错。
解决办法:
所以如果要在TextView中显示int类型的数据,应提前转换成字符串类型。转换方法很多,最简单的就是在int类型数据后加上一个空字符串,如:
textView1.setText(percent+"");
参考:http://blog.csdn.net/wangfayinn/article/details/7716165
Android错误:W/ResourceType(2411): No package identifier when getting value for resource number 0x的更多相关文章
- No package identifier when getting name for resource number 0x00000000
貌似在新版本的SDK下有时会出现标题的这个warning~ 如下: 思前想后也不知道这个到底是说的哪里的问题,在逛谷歌的时候无意中发现有人说是因为xml中color的参数直接写成: android: ...
- TextVeiw 的 No package identifier when getting value for resource numb
tv_title,tv_detail,tv_comment都是TextView; newInfo.getComment()得到的是int类型 tv_title.setText(newInfo.getT ...
- Gradle DSL method found: ‘android()’错误
Gradle DSL method found: ‘android()’错误 和上个错误一样这个也是因为在新版本的Gradle中android()方法已经废弃,但是要注意android()只是在整个项 ...
- Android - 错误:"No resource found that matches the given name android:Theme.Material"
Android - 错误:"No resource found that matches the given name android:Theme.Material" 本文地址: ...
- Hibernate错误——No row with the given identifier exists
错误 是用的是Hibernate自动建立的数据表,在进行数据库操作时,出现错误No row with the given identifier exists 解决 关系数据库一致性遭到了破坏,找到相关 ...
- android 错误收集
2. is not translated in Eclipse > Preference > Android > Lint Error Checking的Correctness: M ...
- android 错误处理思维随笔
错误信息:An error occurred while preparing SDK package Android SDK Build-Tools 26.0.1 错误分析:大概率更新超时:小概率上次 ...
- Android 错误集合
1. Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 erro ...
- Android错误:can not get file data of lua/start_v2.op [LUA ERROR] [string "require "lua/start_v2””] 已解决
错误: can not get file data of lua/start_v2.op [LUA ERROR] [string "require "lua/start_v2””] ...
随机推荐
- select 框option添加属性 js计算价格 保持两位小数
<select name="" id=""> <volist name="v['childList']" id=" ...
- loadrunner中变量和参数之间的转化实例
1.变量转换成参数值的两种方法: 方法一: char *test="Agoly"; lr_save_string(test,"testPa"); lr_e ...
- Tomcat不输入项目名进入自己项目(根目录指向自己的项目)
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDepl ...
- Liferay 6.2 改造系列之四:重新整理Application添加页面默认提供的Portlet清单
经过2.3两步后,剩余Portlet已经不多,添加Application页面如下: 将用不到的Portlet隐藏起来:11 Portal目录 (Portal Directory) 将内嵌Protl ...
- 上传文件大于 2G以上
1. 开始->运行中输入以下路径, 回车. %windir%\system32\inetsrv\config\applicationhost.config 2. 在打开的配置文件中搜索" ...
- HttpHandler与HttpModule的用处与区别
问题1:什么是HttpHandler? 问题2:什么是HttpModule? 问题3:什么时候应该使用HttpHandler什么时候使用HttpModule? 答案1:HttpHandler,Http ...
- WordPress ”无法发送电子邮件,可能原因:您的主机禁用了mail()函数“的解决办法
WordPress网站中出现 "无法发送电子邮件,可能原因:您的主机禁用了mail()函数"的情况一般都是因为所在主机环境不支持在线邮件收发功能导致,如果不支持的话,那么像类似 N ...
- 2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest D. Do it Right!
D. Do it Right! time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- iOS学习14之OC NSNumber + NSValue
1.NSNumber 数值类. 作用:实现基本数据类型与OC对象类型的相互转化. 1> NSNumber创建对象 // 初始化方法 NSNumber *num1 = [[NSNumber all ...
- Codeforces Round #364 (Div. 2) B. Cells Not Under Attack
B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...