I am trying to use PhoneNumberFormattingTextWatcher but there is nothing happening as if the code is not there
here is the code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
EditText PhoneEdit = (EditText) findViewById(R.id.editText1);
PhoneEdit.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}
when entering 002010555666 it still the same no - or + or (), just the same without any formatting is there anything missing in the code
help
Have had the same issue, but after removing android:digits="1234567890+"
it gone.
I added a comment to YTerle's answer, but I wanted to put the complete answer below:
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="@string/phone_number"
android:layout_marginBottom="5dp"
android:ems="10"
android:maxLength="14"
android:id="@+id/phone" />
Then in the code put the following:
phoneView.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
I was having issues even after adding android:inputType="phone"
in the XML.
The solution was to set the Language in the phone:
Settings -> Search for Language -> pick English (United States)
The format (999) 999-9999 is mostly used in the US, therefore the phone language should be set to that only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With