Convert edit text to dual android

I have 2 editing texts, and since I want to make them decimal, I cannot make them whole, so I need to turn them into double ones. I have this code, but in the n2Var 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!

+4
source share
1 answer

You have it in n2Var

 double n2Var = Double.parseDouble(n2,getText().toString());

instead

 double n2Var = Double.parseDouble(n2.getText().toString());
+6
source

Source: https://habr.com/ru/post/1629074/


All Articles