由于一个粗心造成的RuntimeException
2016-01-22 15:22
363 查看
今天在测试时候,老是有一个TextView报错,以下是错误日志:
罪魁祸首就是reservedCount这个变量(int类型)。
再来看看TextView.setText的方法:
看到这里,就知道了,原来这执行这行代码的时候,系统去R.Java里面寻找ID为0(上面的reservedCount值为0)的String,没有找到。
到此,终于排雷成功。It’s funny!
java.lang.RuntimeException: Unable to resume activity {com....Activity}: android.content.res.Resources$NotFoundException: String resource ID #0x0 … Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0 … at com.gidoor.runner.ui.main.OrderManagerActivity.setOrderCountValue(...Activity.java:133)
定位到相关代码:罪魁祸首就是reservedCount这个变量(int类型)。
再来看看TextView.setText的方法:
final void | setText(int resid) |
final void | setText(char[] text, int start, int len) Sets the TextView to display the specified slice of the specified char array. |
final void | setText(int resid, TextView.BufferType type) |
final void | setText(CharSequence text) Sets the string value of the TextView. |
void | setText(CharSequence text, TextView.BufferType type) Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable. |
到此,终于排雷成功。It’s funny!
相关文章推荐
- ADT开发中的一些优化设置:代码自动补全等
- Python爬虫模拟登录带验证码网站
- Paint的画Text(drawText)最全解析
- 高效的使用 top
- 案例—考勤后台管理系统需求
- Shell commands
- 手把手教你把Vim改装成一个IDE编程环境(图文)
- linux Futex
- LR(Logistic Regression)深入理解
- ProGuard 应用Gradle Task
- Android将两个bitmap合并
- 高级编程之网络编程(二)
- APP测试基本流程
- MySql的存储引擎
- 解决spawn-fcgi child exited with: 1
- Solr in Action 第一章翻译(待整理)
- linux命令行将已有项目提交到github
- 啥是web service,通俗易懂的一篇文章
- Project Euler 107:Minimal network 最小网络
- drbd+nfs+heartbeat高可用