Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Validate an EditText to handle numbers only in Android?

How can I validate a text view in android to handle positive integer numbers?

I don't want it to accept any character or signs etc...

like image 514
Hamza M. S. Abazeed Avatar asked Dec 04 '22 17:12

Hamza M. S. Abazeed


1 Answers

Have you taken a look at the EditText's inputType attribute? You can set a whole bunch of different input types that the EditText should limit the user input to.

From the sounds of it, you're probably looking for something like:

<EditText
    ....
    android:inputType="number" 
     ... />
like image 68
MH. Avatar answered Jan 01 '23 03:01

MH.