弱笔琉璃

导航

TextVeiw 的 No package identifier when getting value for resource numb

tv_title,tv_detail,tv_comment都是TextView;

newInfo.getComment()得到的是int类型

tv_title.setText(newInfo.getTitle());
tv_detail.setText(newInfo.getDetail());
tv_comment.setText(newInfo.getComment());

这段代码会抛 No package identifier when getting value for resource numb 异常

 

原因:TextView 的setText方法把传入的int类型的值当做资源Id到项目中查询资源,而资源中却找不到相应的数值,就会报NotFoundException的错误。

解决:

1.

tv_comment.setText(String.valueOf(newInfo.getComment()));

2.

tv_comment.setText(newInfo.getComment()+"");

  

posted on 2015-10-04 19:48  弱笔琉璃  阅读(239)  评论(0)    收藏  举报