Travis CI Codecov Maven Central Nexus Snapshot Android SDK

CountryPicker

Dialog preview. Bottom sheet dialog.

Material design components to pick country.

Download

repositories {
    google()
    mavenCentral()
}
dependencies {
    implementation "com.hendraanggrian.material:countrypicker:$version"
}

Usage

Dialog

Use CountryPickerDialog.Builder to build or show CountryPickerDialog.

new CountryPickerDialog.Builder(context)
  .setOnSelectedListener(new CountryPicker.OnSelectedListener() {
    @Override
    public void onSelected(@NonNull Country country) {
      // do something
    }
  })
  .show();

Bottom Sheet

No builder here, create traditionally.

BottomSheetDialog dialog = new CountryPickerSheetDialog(context);
dialog.setOnSelectedListener(new CountryPicker.OnSelectedListener() {
  @Override
  public void onSelected(@NonNull Country country) {
    // do something
  }
});
dialog.show()

Custom Flags

To use custom flag images, have a drawable with name format flag_{2-digit iso code} in your project. For example if you want to display US flag, the drawable name should be flag_us.

See Country.java for all available country codes.