How to force EditText to accept only numbers?

Solution 1:

Use android:inputType="number" in your layout XML

Solution 2:

This also works fine:

android:digits="0123456789"