Possible Duplicate:
Android How do you set the max number of characters for an EditText
How can I prevent the user from entering more than 4 numbers in edittext ? thanks
Possible Duplicate:
Android How do you set the max number of characters for an EditText
How can I prevent the user from entering more than 4 numbers in edittext ? thanks
This is fairly easy task that can be learned from documentation, but nevertheless.
The answer to your question consists of two parts:
The first part can be achieved using android:inputType="number"
. The other one can be achieved by using android:maxLength
field. So the final result would be:
<EditText ...
android:inputType="number"
android:maxLength="4"
android:lines="1"/>