Format EditText view for phone numbers

后端 未结 8 1799
既然无缘
既然无缘 2020-12-28 20:49

I have an EditText view and I want it to format the user\'s input into the phone number format. For example, when the user types in 1234567890, the EditText view should dyna

8条回答
  •  庸人自扰
    2020-12-28 21:14

    Step 1: Here the code for input field in XML file.

     
    

    Step 2: Here is the code add into the MainFile.java

     phoneNo = (EditText)findViewById(R.id.editText_phone);
     phoneNo.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    

    Output: It will give you the number like (123)456-7890

提交回复
热议问题