android錯誤之android.content.res.Resources$NotFoundException:
錯誤:android.content.res.Resources$NotFoundException: String resource ID #0x1
原因:一般發生在引數 int resId 錯誤,你把String賦值給int的resId,所以編譯器找不到正確的resource於是報錯。
最簡單的例子,檢查一下你的Toast.makeText()啊textView.setText啊之類的函式,這種函式通常有幾個過載,如:
textView.setText(CharSequence text);
textView.setText(int resId);
......
如果不小心將一個int值傳給了它,那它不會顯示該int值,而是跑到工程下去找一個對應的resource的id,當然是找不到的,於是就報錯啦。
比如我這裡是這樣的:
count.setText(incall.getCount());
incall.getCount();返回的是一個int值,直接setText肯定不行啊,就是上面的錯誤型別,
解決辦法就是
count.setText(String.valueOf(incall.getCount()));
或者
count.setText(incall.getCount() + "");
超級簡單,但是如果注意不到就讓人抓狂,明明沒錯嘛!你報個妹的錯!再錯我砸了你!!!
息怒..........
作者:jason0539