Android Edittext number only

android, android-input-method

Solution

Try using this method

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

Problem

I have a a Edittext field that is dynamically created I have it so that the input method is number only. However it is still possible to paste text into the field. Is there anyway of preventing this without having to do post validation? My code to for input method is currently: ``` editText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); ```

Original source