How do I restrict my EditText input to numerical (possibly decimal and signed) input?

Solution 1:

There's no reason to use setRawInputType(), just use setInputType(). However, you have to combine the class and flags with the OR operator:

edit.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);

Solution 2:

Try using TextView.setRawInputType() it corresponds to the android:inputType attribute.