Rob S. Rob S. - 1 year ago 110
Android Question

How do I return an int from EditText? (Android)

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?

Thanks in advance to any and all responses which I receive.

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download