When creating an EditText in the java portion of the application, how do you limit it to numbers like you would in the xml? For example:
new EditText(this);
set like
<EditText
android:id="@+id/h1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"/>
Use of
android:numeric
is deprecated, useandroid:inputType=number
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
.Something like this perhaps ?