I developed an App that asks the user to input ID and Phone number. Using Android, I want to limit the digits of the inputting number. My boxes of type numbers.
Asked
Active
Viewed 760 times
0
-
Are you only going to support phone numbers from one country? Usually for this kind of thing, you want to make it robust so that it works with all countries and their specific phone number formats. In the past I used Google's libphonenumber (see here: http://stackoverflow.com/a/21271035/4409409 ) and a PhoneNumberFormattingTestWatcher: https://developer.android.com/reference/android/telephony/PhoneNumberFormattingTextWatcher.html – Daniel Nugent May 28 '16 at 00:30
-
thank you for these links they really help me a lot – moalbait May 28 '16 at 03:22
1 Answers
3
use android:maxLength
as an attribute in your EditText
For example:
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="12"/>

Abdallah Alaraby
- 2,222
- 2
- 18
- 30