Android: Limiting EditText to numbers
this will usually do it:
android:numeric="integer"
Go to the docs and look at the table with XML attributes. It shows you the code equivalent of each item.
In this case, it's setRawInputType
.
Use of android:numeric
is deprecated, use android:inputType="number"
Something like this perhaps ?
EditText text = new EditText(this);
text.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);