Reputation: 107
I have 2 edit texts and because I want to make them decimals I can not make them integers so I have to turn them into a double. I have this code but in the n2Var get text I have an error.
mul = (Button) findViewById(R.id.button);
n1 = (EditText)findViewById(R.id.editText);
n2 = (EditText)findViewById(R.id.editText2);
ans = (EditText)findViewById(R.id.TextView10);
double n1Var = Double.parseDouble(n1.getText().toString());
double n2Var = Double.parseDouble(n2,getText().toString());
Thanks for any help!
Upvotes: 9
Views: 29228
Reputation: 171
in Kotlin you can use this..
edittext.text.toString().toDouble()
Upvotes: 7
Reputation: 2493
You have this in n2Var
double n2Var = Double.parseDouble(n2,getText().toString());
instead of
double n2Var = Double.parseDouble(n2.getText().toString());
Upvotes: 15