PhoneNumberFormattingTextWatcher不适用于特定的美国电话号码

时间:2018-04-06 12:11:59

标签: java android android-textwatcher

我正在使用PhoneNumberFormattingTextWatcher格式化美国格式的电话号码。
但是,当我们输入数字1111111111时,它无法格式化它。
对于其他数字,如2222222222,它可以正常工作。

  

例如:输入:2222222222
输出:(222)222-2222

对此的任何见解都会有所帮助。

我的代码:

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);

    }
  });

}

0 个答案:

没有答案