我试图从 EditText 获取字符串并解析为双精度。但我遇到了一个错误。
09-26 10:42:41.589: E/AndroidRuntime(17901): FATAL EXCEPTION: main
09-26 10:42:41.589: E/AndroidRuntime(17901): java.lang.NumberFormatException:
09-26 10:42:41.589: E/AndroidRuntime(17901): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267)
09-26 10:42:41.589: E/AndroidRuntime(17901): at java.lang.Double.parseDouble(Double.java:318)
09-26 10:42:41.589: E/AndroidRuntime(17901): at br.com.going2.Checkincomercial.NovoCheckinActivity$4.onClick(NovoCheckinActivity.java:219)
代码
String controle = "";
controle = etCustoNovoCheckin.getText().toString();
if( controle == null || controle == ""){
custo = 0.0;
} else {
custo = Double.parseDouble(controle);
}