0

How can I format an EditText to follow the "######-##-####" format or input mask in android? And this EditText only allow number. How can i do that? just an example, when the user enter 123456781234 it will change to 123456-78-1234 The Edittext will automatically put "-" using the number given. If anyone can help and show the code, it will help me alot. Thanks..

Diana Hudson
  • 3
  • 1
  • 4
  • Refer this http://stackoverflow.com/questions/3890325/whats-the-best-way-to-apply-a-mask-to-an-edittext-on-android – Anil Jadhav Aug 12 '14 at 08:29
  • guys... If u can show the working code... it will help me.. i need it automatically put the "-" when the user enter the number in edittext... hope u can help... – Diana Hudson Aug 12 '14 at 08:47

1 Answers1

0

Try this way,hope this will help you to solve your problem.

String formattedNumber = PhoneNumberUtils.formatNumber(unformattedNumber);

Take a look at PhoneNumberUtils for more options.

Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67