java - custom phone number formatting -


I would want me to format your phone number in Android application, but still do method

I've read about the phone number, and so on, but just could not find any way to do this because all Libds US , German < / Code>, French and other formats. I want to support the Russian and this Libs is not working properly.

The only way I make my own formatting

For example, if I type

  79123456789  

It is here to be in this format.

  +7 (912) 345-67-89  

I found libs IOS (SHSPhoneTextField), but in Android I was not.

Can anyone tell me a good solution here?

  mPhoneNumber.addTextChangedListener (New PhoneNumberFormattingTextWatcher () {@Override public void beforeTextChanged (CharSequence charSequence Int I, I2 Integer, Integer i3) {} @Override public void onTextChanged (CharSequence charSequence, I Int, int i2, integer i3) {if (charSequence.length () == 11) mPhoneNumber.setText (PhoneNumberUtils.formatNumber (charSequence.toString ()));} @Override {public void afterTextChanged (editable editable)}}) ;  

Maybe this will help (PhoneNumberUtils):

< P> A small example:

  string formatted number = phone number utility format number (unchanged number);  

This will automatically be number format according to the rules for country number.

See PhoneNumberUtils for more options.


Comments