报错信息:

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. JSON.parse()和JSON.stringify()使用

    JSON.parse()用于从一个字符串中解析出json对象,如 var str = '{"name":"huangxiaojian","age&qu ...

  2. DSP using MATLAB 示例 Example3.11

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...

  3. 比较全的JS checkbox全选、取消全选、删除功能代码

    看下面两种实现方法: JS checkbox 方法一: 复制代码 代码如下: function checkAll() { var code_Values = document.all['code_Va ...

  4. HTML <!DOCTYPE> 标签

    在默认情况下,FF和IE的解释标准是不一样的,也就是说,如果一个网页没有声明DOCTYPE,它就会以默认的DOCTYPE解释下面的HTML.在同 一种标准下,不同浏览器的解释模型都有所差异,在默认情况 ...

  5. React组件

    React组件 组件是React中的基本单位,在每个组件里面又封装了程序逻辑,通过reader标出界面片段或者回传一段描述,组件再通过React.renderComponent将组件展示在浏览器中.每 ...

  6. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

  7. Posterior visual bounds retrieval for the Plato framework

    Plato is a MVVM compliant 2D on-canvas graphics framework I've been designing and implementing for d ...

  8. Codeforces Round #195 (Div. 2) A. Vasily the Bear and Triangle

    水题,注意数据范围即可 #include <iostream> #include <algorithm> #include <utility> using name ...

  9. Coder-Strike 2014 - Round 1 D. Giving Awards

    题目的意思是 老板给n个人发工资,x欠y的工资,the joy of person x from his brand new money reward will be much less, 老板想避免 ...

  10. ACM 擅长排列的小明

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想 ...