Android報“android.content.res.Resources$NotFoundException: String resource ID xxx”錯誤
錯誤情形
使用TextView
的setText
方法,報錯資源找不到。
.setText(R.id.read_num,item.getReadNum())
解決
這裏item.getReadNum()
是一個int,setText
方法如果直接穿一個數字參數,會被當作是資源id,定位該資源發現找不到就會爆粗。所以只要轉成字符串就可以了。
.setText(R.id.read_num, “” + item.getReadNum())