Reputation: 1679
I am using PhoneNumberFormattingTextWatcher on my editText fields I noticed that it does not format numbers which start with 11, but treats them as normal string. Why is this. And is there a work around to curb the issue ?
This is the XML:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="8">
<!-- INPUT -->
<EditText
android:id="@+id/etMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_size_8"
android:layout_marginBottom="@dimen/dp_size_8"
android:background="@null"
android:ems="10"
android:hint="@string/edt_mobile"
android:inputType="phone"
android:maxLength="14"
android:paddingTop="@dimen/dp_size_2" />
</android.support.design.widget.TextInputLayout>
This is the usage in the java activity:
etMobile.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
The current local is
US
Expected number format is
1 222-222-2222
1 333-333-3333
But when a "1" follows after the initial "1", I get
11111111111111
Upvotes: 0
Views: 570
Reputation: 11
It might be that numbers starting with 11 are not a recognized phone number for your given locale to PhoneNumberFormattingTextWatcher. In my case it was any number starting with 7, 6 or 2.
If you want a work around you can always make your own text watcher or make use of format number function of PhoneNumberUtils.
Upvotes: 1