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””] ...
随机推荐
- Java反射详解及应用示例
反射是Java中最重要的内容之一,了解反射原理对我们学习各种框架具有很大的帮助 反射的原理: 反射应用示例: import java.lang.reflect.Constructor; import ...
- 【java 获取数据库信息】获取MySQL或其他数据库的详细信息
1.首先是 通过数据库获取数据表的详细列信息 package com.sxd.mysqlInfo.test; import java.sql.Connection; import java.sql.D ...
- 【spring】 <tx:annotation-driven /> 的理解 【转载的】
在使用SpringMvc的时候,配置文件中我们经常看到 annotation-driven 这样的注解,其含义就是支持注解,一般根据前缀 tx.mvc 等也能很直白的理解出来分别的作用.<tx: ...
- 滚动到底部加载更多及下拉刷新listview的使用
最新内容建议直接访问原文:滚动到底部加载更多及下拉刷新listview的使用 本文主要介绍可同时实现下拉刷新及滑动到底部加载更多的ListView的使用. 该ListView优点包括:a. 可自定义下 ...
- Android手机自动化测试真机运行
一, 打开手机的USB调试模式 不同的手机有不同的方法打开usb调试模式,可是去网上查一下你手机的调试模式打开办法(http://wenku.baidu.com/view/3077f06c25c ...
- 上传文件大于 2G以上
1. 开始->运行中输入以下路径, 回车. %windir%\system32\inetsrv\config\applicationhost.config 2. 在打开的配置文件中搜索" ...
- wcf,socket,数据传输方式
WCF的最终目标是通过进程或不同的系统.通过本地网络或是通过Internet收发客户和服务之间的消息. WCF合并了Web服务..net Remoting.消息队列和Enterprise Servic ...
- iOS UIImageView用代码添加点击事件
image.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]ini ...
- linux 查看机器的cpu,操作系统等命令
看cpu信息,型号,几核 [root@f3 ~]# cat /proc/cpuinfo | grep name | cut -f2 -d:| uniq -c 16 Intel(R) Xeon(R) C ...
- RMI之HelloWorld尝试
服务器端代码如下: IHello接口: import java.rmi.Remote; import java.rmi.RemoteException; public interface IHello ...