Exact error that you get would be nice. Without it it is just guess work
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
1. Your above post was moved from Java to Mobile Development, I do not understand why you posting there
2. As expected your are completely ignoring that parseDouble or valueOf can actually trow NumberFormatException.
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Well either you are entering non-numeric value and that is triggering exception or you are not able retrieve text input therefore input.getText().toString return null and that cause exception. Since you did not post enough code I can't say for sure what is wrong
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Solution 1, use try and catch as mentioned previosly
private double Doublify(EditText editText){
try {
return Double.parseDouble(input.getText().toString());
} catch (NumberFormatException e) {
return 0;
}
}
Solution 2, configure EditText to accept numbers only
<EditText android:inputType="numberDecimal" />
by declaring inputType
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902