Skip to content

Custom Master Country List

Harsh Bhakta edited this page Jan 11, 2018 · 2 revisions
  • If your app expects users from only few countries then you might wish to remove all other countries from selection list.
    • You can remove unnecessary countries by setting your custom master country list.

    • Also it will keep user from selecting irrelevant country.

    • Countries of preference will be listed at top in selection dialog. It is helpful when target audience is from a set of countries.

    • Custom master list will only limit the visibility of irrelevant countries from selection dialog. But all other functions like setCountryForCodeName() or setFullNumber() will consider all the countries.

    • Preferred country list will be a subset of custom master list. If some xyz country is not in custom master list, it won't be added to preferred country list.

    • Set through xml

      • add app:ccp_customMasterCountries="US,IN,NZ,BD,PL,RO,ZW" (replace "US,IN,NZ,BD,PL,RO,ZW" by your own country code names) to xml layout. Refer List of countries for name codes.

         <com.hbb20.CountryCodePicker
          android:id="@+id/ccp"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:ccp_customMasterCountries="US,IN,NZ,BD,PL,RO,ZW"  />
    • Programmatically

      • Use setCustomMasterCountries() method.
      • setCustomMasterCountries(null); will remove custom list and revert to library default list.
Clone this wiki locally