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””] ...
随机推荐
- kafka producer源码
producer接口: /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor l ...
- bootstrap的图标无法正常显示解决方法
bootstrap的图标无法在火狐浏览器上正常显示,出现的是乱码,如下图所示: 解决方案: 直接把bootstrap整个文件夹放到项目中,引用的时候../static/bootstrap-3.3.5- ...
- 我的c++学习(2)比较两个数字大小
#include "stdafx.h" #include<iostream> using namespace std; int max(int i, int j){ / ...
- jQuery WipeTouch
有时,当你只想为触屏划动添加事件时,很多人可能会想到,Jquery mobile,但就这么个功能就把人家这么高大上的东西引用进来就有点大才小用了,WipeTouch是国外某程序员写的针对触屏划动的jq ...
- Android自动化测试 - MonkeyRunner(二) 锤子便签测试脚本
来源于:http://testerhome.com/topics/878 # encoding=utf-8 #导入python中自带的time模块和sys模块,脚本中都要用到它们. import ti ...
- 快速搭建Webservice接口测试环境
一.必备工具: apache-tomcat.Axis2(WebService引擎).实例类 二.部署步骤: 1.到apache官网 http://apache.org/ 下载apache-tomcat ...
- 《Getting Started with Storm》译文 Homepage
拿到这本书感觉还挺薄,所以当下就想赶紧读完,然后尝试着翻译下,并加上一些自己的理解,作学习交流之用,非盈利性质 这段时间在做一个 分布式的.支持大吞吐的.实时的日志系统 ,主要用到的开源方案有Kaf ...
- Shell 编程基础之 Break, Continue 练习
一.语法 break:用来跳出循环.break N 可以跳出多层循环 break break N continue:用来跳过循环.continue N 可以跳过多层循环 continue contin ...
- BZOJ2158 : Crash 的旅行计划
A类数据: $n,q\leq1000$ 修改:$O(1)$直接改 查询:$O(n)$BFS B类数据: $n,q\leq100000$,保证是一条链 用线段树维护区间最大前缀.后缀和 修改:$O(\l ...
- Android 蓝牙4.0 BLE
Android ble (Bluetooth Low Energy) 蓝牙4.0,也就是说API level >= 18,且支持蓝牙4.0的手机才可以使用. BLE是蓝牙4.0的核心Profil ...