Reputation: 27
How do I allow only numbers in an EditText
. I don't want to allow decimals or letters, but only numeric values.
Upvotes: 2
Views: 984
Reputation: 6915
JAVA : edittext.setRawInputType(InputType.TYPE_CLASS_NUMBER);
in XML:
<EditText
// ...
android:inputType="number"
// ... />
Upvotes: 1
Reputation: 884
In addition to the above comments, this will also work(However, it does not make the keyboard switch to number mode) :
android:digits="0123456789"
Upvotes: 2