Reputation: 65
Here's the code I'm using:
EditText ii1 = (EditText)findViewById(R.id.i1);
String iii1= (String)ii1.getText().toString();
ind1=Double.parseDouble(iii1);
I need that ind1 acquire value 0 if the EditText is empty.
I already tried using if (ii1 = "")
and if (iii1= "")
, but didn't work. How can I do that??
Thanks!
UPDATE:
Got it using this code: if (iii1.equals("")) {ind1=0;} else {ind1 = Double.parseDouble(iii1);}
Thank you all for the help!
Upvotes: 0
Views: 529
Reputation: 209
You sould compare strings with
iii1.equals("")
instead of iii1 = ""
And please, names like "iii1" are suicide sooner or later...
Upvotes: 0