Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Edittext number only

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);
like image 627
user2029541 Avatar asked Sep 18 '26 06:09

user2029541


1 Answers

Try using this method

.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
like image 86
Marcus Avatar answered Sep 20 '26 19:09

Marcus