錯誤提示信息:
W/ResourceType(6991):
No package identifier when getting value for resource number 0x00000003
W/dalvikvm(8564): threadid=1: thread exiting with uncaught exception (group=0x415f7498)
代碼位置:
private int orderAmount;
textView.setText(order.orderAmount);
錯誤原因:
主要是因為TextView的setText方法會把傳入的int類型的變量當做資源Id到項目中查詢資源移剪,而資源中卻找不到相應的數(shù)值,就會報NotFoundException的錯誤。
在Android中利用id來索引資源的地方很多(如:Toast.makeText()等),所以如果不小心往方法中傳入int類型的參數(shù)醇王,雖然編譯時IDE不會報錯朵你,但是運行時,很容易因找不到對應的資源而報錯蝴光。
解決方法:轉換為字符串類型
private int orderAmount;
textView.setText(String.valueOf(order.orderAmount));