这是我的代码:
TextView headerVal = (TextView) nextChild.findViewById(R.id.textView3);
String tt = ((String)headerVal.getText()).replaceAll(",",""); //it was 1,000 and it became 1000
int longueur = tt.length();
String aux2 = (String) tt.substring(0,longueur - 2);
int contenu = (int) Integer.parseInt(aux2);// here is the error "unable to parse 1000 as an integer".
PS:它可以在模拟器上运行,但我在手机上遇到了这个错误
日志猫:
04-04 13:04:15.210: E/AndroidRuntime(31718): FATAL EXCEPTION: main
04-04 13:04:15.210: E/AndroidRuntime(31718): java.lang.NumberFormatException: unable to parse '1 000' as integer
04-04 13:04:15.210: E/AndroidRuntime(31718):at java.lang.Integer.parse(Integer.java:433)
04-04 13:04:15.210: E/AndroidRuntime(31718):at java.lang.Integer.parseInt(Integer.java:422)
04-04 13:04:15.210: E/AndroidRuntime(31718):at java.lang.Integer.parseInt(Integer.java:382)
04-04 13:04:15.210:E/AndroidRuntime(31718):at com.example.appui.BarGraphActivity.setColumnParts(BarGraphActivity.java:408)
04-04 13:04:15.210: E/AndroidRuntime(31718):at com.example.appui.BarGraphActivity.access$2(BarGraphActivity.java:282)
04-04 13:04:15.210: E/AndroidRuntime(31718):at com.example.appui.BarGraphActivity$Desired_pension.onStopTrackingTouch(BarGraphActivity.java:162)