Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:35:01+00:00 2026-05-28T01:35:01+00:00

I want to set this format phone no 223-233-3334 for edit text when user

  • 0

I want to set this format phone no 223-233-3334 for edit text when user typing in keyboard .i know i have to use dialerkeylistener and textfilter .can anybody give sample how to use dialerkeylistener to set format in android

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:35:02+00:00Added an answer on May 28, 2026 at 1:35 am

    For non-NANP (http://www.howtocallabroad.com/nanp.html) countries to implement phone number formatting while user typing, you can use some workaround like this:

    yourEditText.addTextChangedListener(new TextWatcher() {
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
    
                    String typedNum = yourEditText.getText().toString();
                    if(typedNum.length() == 3)
                    {
                        yourEditText.setText(typedNum + "-");
                    yourEditText.setSelection(4);
                    }
                    else if(typedNum.length() == 7)
                    {
                        yourEditText.setText(typedNum + "-");
                        yourEditText.setSelection(8);
                    }
    
                }
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count,
                        int after) {
                }
                @Override
                public void afterTextChanged(Editable s) {
                }
            });
    

    Otherwise solution can be :

    import android.telephony.PhoneNumberFormattingTextWatcher;
    

    OnCreate :

    yourEditText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
    

    If you like to format the number after user has entered the phone number:

      import android.telephony.PhoneNumberUtils;
    

    OnCreate :

    PhoneNumberUtils.formatNumber(Editable text, int defaultFormattingType);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom DataGridView control and want to set the text format for
I want to set date in this format MMM dd, yyyy HH:mm, I hede
I'm using magnolia and I have this variable: ${def.parameters.subTemplate} I want to set the
I want to achieve this using html and css: I have tried to set
i have a string with a date in this format yyyyMMddHHmmss, so i want
I need to set an alarm on a user's phone. This is an android
Say I have a set of data in this format: ID Product account open
I want to insert a vector into a set like this: set<vector<prmEdge> > cammini;
I want to set the menu to active when click on it. This is
in my site i want to set default page to open, using this script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.