Basically, I want an EditText in Android where I can have an integer value entered into. Perhaps there is a more appropriate object than EditText for this?
The Best Answer is you have to used. String value= et. getText(). toString(); int finalValue=Integer.
Now, before we start we need to know some method of EditText which we use to get or fetch the text written in an EditText that is . getText() method and the other one is . setText() method that we use to set some pre-written text or string. EditText demo; demo=(EditText)findViewById(R.
The method used to get the data from an EditText is getText().
For now, use an EditText
. Use android:inputType="number"
to force it to be numeric. Convert the resulting string into an integer (e.g., Integer.parseInt(myEditText.getText().toString())
).
In the future, you might consider a NumberPicker
widget, once that becomes available (slated to be in Honeycomb).
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