Using Textwatcher To Get Values Entered To Two Edittext And Multiplying These Values Without A Button. Automatic Computation.
I want the app to automatically compute when the user enters the requested two values into edittext, without needing a button. Is there a way to do it without using TextWatcher? he
Solution 1:
You should set the default values of the edittext to 0. Its probably force closing because you are trying to parse an empty string from an edittext that has nothing in it;
EDIT: try this
if (height != null)
heightInt = Double.parseDouble(!height.getText().toString().equals("")?
height.getText().toString() : "0");
if (weight != null)
weightInt = Double.parseDouble(!weight.getText().toString().equals("")?
weight.getText().toString() : "0");
this way your using a condition where no matter what youll be parsing a value that wont throw an exception
Post a Comment for "Using Textwatcher To Get Values Entered To Two Edittext And Multiplying These Values Without A Button. Automatic Computation."