报错信息:

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的更多相关文章

  1. No package identifier when getting name for resource number 0x00000000

    貌似在新版本的SDK下有时会出现标题的这个warning~  如下: 思前想后也不知道这个到底是说的哪里的问题,在逛谷歌的时候无意中发现有人说是因为xml中color的参数直接写成: android: ...

  2. 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 ...

  3. Gradle DSL method found: ‘android()’错误

    Gradle DSL method found: ‘android()’错误 和上个错误一样这个也是因为在新版本的Gradle中android()方法已经废弃,但是要注意android()只是在整个项 ...

  4. Android - 错误:"No resource found that matches the given name android:Theme.Material"

    Android - 错误:"No resource found that matches the given name android:Theme.Material" 本文地址:  ...

  5. Hibernate错误——No row with the given identifier exists

    错误 是用的是Hibernate自动建立的数据表,在进行数据库操作时,出现错误No row with the given identifier exists 解决 关系数据库一致性遭到了破坏,找到相关 ...

  6. android 错误收集

    2. is not translated in Eclipse > Preference > Android > Lint Error Checking的Correctness: M ...

  7. android 错误处理思维随笔

    错误信息:An error occurred while preparing SDK package Android SDK Build-Tools 26.0.1 错误分析:大概率更新超时:小概率上次 ...

  8. Android 错误集合

    1. Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 erro ...

  9. 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””] ...

随机推荐

  1. LoadRunner之安装、破解、汉化教程(一)

    安装前,把所有的杀毒软件和防火墙关闭 安装前,把所有的杀毒软件和防火墙关闭 安装前,把所有的杀毒软件和防火墙关闭........     注意事项: 安装前,把所有的杀毒软件和防火墙关闭. 若以前安装 ...

  2. Tomcat不输入项目名进入自己项目(根目录指向自己的项目)

    <Host name="localhost" appBase="webapps" unpackWARs="true" autoDepl ...

  3. psql-07表:分区表

    表继承与分区表 表继承 表继承是PostgreSQL特有的 create table persons ( age int, sex boolean ); create table students ( ...

  4. 转 Delphi Invalidate的用法

    1.Invalidate介绍 void Invalidate( BOOL bErase = TRUE ); 该函数的作用是使整个窗口客户区无效.窗口的客户区无效意味着需要重绘,例如,如果一个被其它窗口 ...

  5. 关于fragment保存变量的问题

    之前遇到一个问题:某个fragment在打开改变状态好后,然后关闭,要求是再次打开时该状态依然保留 这时候求度娘.自己解决问题后,现在整理过程如下: 1.新定义Bundle saveState=new ...

  6. Sphinx 全量索引加实时索引

    source mysql { type = mysql sql_host = 10.10.3.181 sql_user = root sql_pass = dsideal sql_db = dside ...

  7. 读书笔记:javascript高级技巧(一)

    一.安全的类型检测 javascript内置的类型检测机制并非完全可靠,由于浏览器或者作用域等原因,经常会发生错误.大家知道,在任何值调用toString()方法都会返回一个[object Nativ ...

  8. 移动端开发——javascript

    javascript(简称js)语言在移动前端应用很广.可以说必不可少,许多效果都是和js相关的.包括现在移动端的一些框架.jqmobi.jqtouch.sencha touch.jquerymobi ...

  9. [深入浅出WP8.1(Runtime)]应用实例——移动截图

    10.2应用实例——移动截图 移动截图例子是实现一个把一张图片的某个部分截取出来的功能,并且用户可以选定截取的图片区间.那个该例子会使用ManipulationDelta事件来实现对截取区间的选择.然 ...

  10. 3分钟4个步骤超级简单入门配置lamp

    按照我下面的推荐博客进行3步安装,最后进行一步测试就完成了.环境:我的环境是在windows10中安装的VMware中安装的Ubuntu虚拟机,Windows8,7应该是一样的测试:分别用localh ...