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!
To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library. If you want to replicate this behaviour without the library, check out the source code for this small method.
You can use the attribute style="@style/your_style" that is defined for any widget. The attribute parent="@android:style/Widget. EditText" is important because it will ensure that the style being defined extends the basic Android EditText style, thus only properties different from the default style need to be defined.
This is the class for text whose content and markup can both be changed. This is the interface for text whose content and markup can be changed (as opposed to immutable text like Strings). If you make a DynamicLayout of an Editable, the layout will be reflowed as the text is changed.
You have this in n2Var
double n2Var = Double.parseDouble(n2,getText().toString());
instead of
double n2Var = Double.parseDouble(n2.getText().toString());
in Kotlin you can use this..
edittext.text.toString().toDouble()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With