A Country Code Picker Library.

Country Code Picker (CCP) is an android library which provides an easy way to search and select country phone code for the telephone number.

CCP gives professional touch to your well designed form like login screen, sign up screen, edit profile screen.
CCP removes confusion about how to add number and thus make view more understandable. Finally reduces mistakes in user input.

The most recommended usage for CCP is using the default setting so the library will auto check the all the value.
To do that, you need to follow the following steps:

  1. Add CCP view to layout
  2. Add EditText view to layout
  3. register the EditText using registerPhoneNumberTextView(editText) we can also use TextView instead of editText.
  4. Let the magic happens 😉

Step 1: Install it

How to add to your project

  1. Add to your root build.gradle file:
    allprojects {
        repositories {
            maven { url "" }
  1. Add library to your app build.gradle file then sync
    dependencies {
        implementation 'com.github.joielechong:countrycodepicker:2.4.2'

Step 2: Add to Layout

Add ccp view to xml layout

          android:layout_height="wrap_content" />

If you want to Add EditText view to layout:


Step 4: Show in Activity/Fragment:

Add ccp object in Activity / Fragment

    CountryCodePicker ccp;

Then Bind ccp from layout

    ccp = (CountryCodePicker) findViewById(;

That's it. Run the project and see the results.

If you want to register an EditText with code:

   CountryCodePicker ccp;
   AppCompatEditText edtPhoneNumber;


   ccp = (CountryCodePicker) findViewById(;
   edtPhoneNumber = findViewById(;



You can check validity of phone number using isValid() method.


Here the attributes that can be used in CountryCodePicker layout:

Attribute method Description
ccp_defaultCode setDefaultCountryUsingPhoneCodeAndApply(int defaultCode) set selected Flag and phone in CCP by phone code.
ccp_showFullName showFullName(boolean show) Show full name of country in CCP. Default is false
ccp_hideNameCode hideNameCode(boolean hide) Hide the country name code. Default is false
ccp_hidePhoneCode hidePhoneCode(boolean hide) Hide the phone code. Default is false


Read more here.