java - how to make User Input of 10 digit Mobile number into 3 - 3 - 4 pattern -


How to input the user's 10-digit mobile number in 3-3-4 format? For example, 9848098480 (984) -80 9-8480 in Android ??

Simply use, just call:

editText. AddTextChangedListener (New PhoneNumberFormattingTextWatcher ());

Add
To be clear, PhoneNumberFormattingTextWatcher has a phone number number class. The TextWatcher maintains the EditText difference, while you PhoneNumberUtils.formatNumber () each time you change its contents.

or

You can use this:

  & Lt; EditText Android: id = "@ + id / editText1" Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: inputType = "phone" />  

Then try this code:

  last edit text <(edit text) search viviId (com.and.R.id.ititText1); Text.addTextChangedListener (New TextWatcher) {@Override Public Zero onTextChanged (CharSequence is, integer start, integer count, integer count) {Boolean flag = true .. string eachBlock [] = text.getText () toString () partition ( "-"); for (int i = 0; i and lieutenant; each block length; i ++) {if (each block [i] length ()> 4) {flag = false};} if ( Flag) {text.SetOnKeyListener (New OnKeyListener) {@Override Public Boolean onKey (see V, integer keycode, KeyEvent event) {if (keycode == KeyEvent.KEYCODE_DEL) KeyDel = 1; return false;}}); if (keyDel == 0) {If ((((text.getText () () (length () + 1)% 5) == 0) {if (text. GetText () .Testring (). Partition ("-". Length  

Comments