3

I am using PhoneNumberFormattingTextWatcher to format the phone number in US format while it is being entered.
However when we input a number 1111111111 it fails to format it.
For other numbers such as 2222222222 it works fine.

Eg: Input: 2222222222
Output: (222)222-2222

Any insights on this would really help.

My Code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  edit_phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher("US") {
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
      super.onTextChanged(s, start, before, count);

    }
  });

} else {
  edit_phone.addTextChangedListener(new PhoneNumberFormattingTextWatcher() {
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
      super.onTextChanged(s, start, before, count);

    }
  });

}
Monica M
  • 161
  • 3
  • 12

0 Answers0