How do you set EditText to only accept numeric values in Android?

I have an EditText in which I want only integer values to be inserted. Can somebody tell me which property I have to use?


Solution 1:

Add android:inputType="number" as an XML attribute.

Solution 2:

For example:

<EditText
android:id="@+id/myNumber"
android:digits="0123456789."
android:inputType="numberDecimal"
/>