Do this resultsText.setText("" + result);
EDIT:
The reason for crash is simple. When you are doing
editableValue1 = editText1.getText();
it will return a valid editable, and the text inside that will be an empty string if nothing has been entered into the edit text. So when you are entering a number in one of the edit texts, the associated editable will return a proper double value, but for the other edit text box (for which you have not entered anything yet) will return empty string, so your function calculateResult()
will throw NumberFormatException
. Since you are not catching that exception, your app will crash. So to make this long story short, just catch the exception when you are calling calculateResult()
.
public void afterTextChanged(Editable s) {
try {
calculateResult();
} catch (NumberFormatException e) {
e.printStackTrace();
}
}