Android报android.content.res.Resources$NotFoundException: String resource ID xxx 错误

来源:互联网 发布:3dmax专业优化修改器 编辑:程序博客网 时间:2024/06/09 14:30

Android报“android.content.res.Resources$NotFoundException: String resource ID xxx”错误

错误情形

使用TextViewsetText方法,报错资源找不到。

 .setText(R.id.read_num,item.getReadNum())

解决

这里item.getReadNum()是一个int,setText方法如果直接穿一个数字参数,会被当作是资源id,定位该资源发现找不到就会爆粗。所以只要转成字符串就可以了。

 .setText(R.id.read_num, “” + item.getReadNum())
阅读全文
0 0
原创粉丝点击