I'm currently trying to implement this:
I've already done the spinner part, though the phone EditText
, I'm not so sure about how to make a TextWatcher for it.
I have 2 options:
I use:
phoneNumberET.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
Or, I use
phoneNumberET.addTextChangedListener(new PhoneNumberFormattingTextWatcher("countryCode"));
Both of these have their flaws. In #1, it won't properly format since the country code isn't found in the EditText
, but in the Spinner
.
In #2 I can only use this in API level 21 and above.
So, is there a solution that can let me format the phone number properly with a country code from the spinner and be available from below API 21?