I want to make user inputted phone number in an editText to dynamically change format every time the user inputs a number. That is, when user inputs up to 4 digits, like 7144, the editText shows "714-4".
I would like the editText to be dynamically updated to format ###-###-#### whenever the user inputs a digit. how can this be done? also, I am handling more than one editTexts.
Easiest way to do this is to use the built in Android PhoneNumberFormattingTextWatcher.
So basically you get your EditText in code and set your text watcher like this..
EditText inputField = (EditText) findViewById(R.id.inputfield); inputField.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
Nice think about using PhoneNumberFormattingTextWatcher is it will format your number entry correctly based on your locale.