An android library for listing all the countries and user can select the country name, code, dial code and flag.
Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.yesterselga:country-picker-android:2.0'
}
CountryPicker picker = CountryPicker.newInstance("Select Country", Theme.DARK); // dialog title and theme
picker.setListener(new CountryPickerListener() {
@Override
public void onSelectCountry(String name, String code, String dialCode, int flagDrawableResID) {
// Implement your code here
YOU_EDITTEXT.setText(name);
YOUR_IMAGE_VIEW.setImageResource(flagDrawableResID);
picker.dismiss();
}
});
picker.show(getSupportFragmentManager(), "COUNTRY_PICKER");
Done ;)