Phone number formatting an EditText in Android

前端 未结 14 936
情深已故
情深已故 2020-12-02 12:03

I am making a simple Address Book app (targeting 4.2) that takes name, address, city, state, zip and phone.

I want to format the phone number input as a phone number

14条回答
  •  暖寄归人
    2020-12-02 12:31

    Simply Use This :

    In Java Code :

    editText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    

    In XML Code :

    
    

    This code work for me. It'll auto format when text changed in edit text.

提交回复
热议问题