PhoneNumberFormattingTextWatcher not working
I am trying to use PhoneNumberFormattingTextWatcher but nothing happens 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 you enter 002010555666 it still remains the same - or + or (), the same without formatting is there anything in the code
help
source to share
I added a comment to YTerle, but I would like 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, enter the following:
phoneView.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
source to share
I used this in my app and it worked fine in the emulator (Android_4.2_Emulator_Smartphone_Nexus_S, using platform 4.4.2, API 19), but had no effect when run on my Samsung Tab 3 device with platform 4.1.2, API 17. Maybe it is device dependent? The documentation indicates that it was introduced in API 1, so I would have thought it should have all the kinks developed by now, but obviously not.
source to share