Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hbb20/androidcountrypicker
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.
https://github.com/hbb20/androidcountrypicker
android android-library country-flags country-information country-picker country-selection country-selector country-spinner currency-picker kotlin library lightweight multilanguage-support picker
Last synced: 8 days ago
JSON representation
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.
- Host: GitHub
- URL: https://github.com/hbb20/androidcountrypicker
- Owner: hbb20
- License: mit
- Created: 2019-09-20T02:32:07.000Z (about 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-06-04T14:56:17.000Z (5 months ago)
- Last Synced: 2024-10-15T21:26:59.254Z (23 days ago)
- Topics: android, android-library, country-flags, country-information, country-picker, country-selection, country-selector, country-spinner, currency-picker, kotlin, library, lightweight, multilanguage-support, picker
- Language: Kotlin
- Homepage:
- Size: 3.98 MB
- Stars: 104
- Watchers: 1
- Forks: 29
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![visitors](https://visitor-badge.laobi.icu/badge?page_id=AndroidCountryPicker.readme)
[![Add](https://maven-badges.herokuapp.com/maven-central/com.hbb20/android-country-picker/badge.svg?style={style}) ](https://github.com/hbb20/AndroidCountryPicker/blob/develop/CHANGELOG.md)| Country Picker View | Country Picker Dialog |
| --- | ----------- |
| | |### 1. Add dependency
- ```groovy
dependencies {
implementation 'com.hbb20:android-country-picker:X.Y.Z'
}
```
- For latest version, [![Add](https://maven-badges.herokuapp.com/maven-central/com.hbb20/android-country-picker/badge.svg?style={style}) ](https://github.com/hbb20/AndroidCountryPicker/blob/develop/CHANGELOG.md)### 2. Decide your use-case
Default Country Picker View
i. add following to your XML layout```xml
```
ii. modify view / dialog / list config in activity or fragment
```kotlin
private fun setupCountryPickerView() {
val countryPicker = findViewById(R.id.countryPicker)// Modify CPViewConfig if you need. Access cpViewConfig through `cpViewHelper`
countryPicker.cpViewHelper.cpViewConfig.viewTextGenerator = { cpCountry: CPCountry ->
"${cpCountry.name} (${cpCountry.alpha2})"
}
// make sure to refresh view once view configuration is changed
countryPicker.cpViewHelper.refreshView()// Modify CPDialogConfig if you need. Access cpDialogConfig through `countryPicker.cpViewHelper`
// countryPicker.cpViewHelper.cpDialogConfig.// Modify CPListConfig if you need. Access cpListConfig through `countryPicker.cpViewHelper`
// countryPicker.cpViewHelper.cpListConfig.// Modify CPRowConfig if you need. Access cpRowConfig through `countryPicker.cpViewHelper`
// countryPicker.cpViewHelper.cpRowConfig.
}
```ii. [Read More](https://github.com/hbb20/AndroidCountryPicker/wiki/Country-Picker-View) about Country Picker View and available configuration
Custom Country Picker View
i. Read how to create your [Custom Country Picker View](https://github.com/hbb20/AndroidCountryPicker/wiki/Custom-Country-Picker-View)
Launch Country Picker Dialog
i. add following to your Activity/Fragment```kotlin
context.launchCountryPickerDialog { selectedCountry: CPCountry? ->
// your code to handle selected country
}
```ii. [Read More](https://github.com/hbb20/AndroidCountryPicker/wiki/Country-Picker-Dialog) about CountryPicker Dialog and available configuration
Load countries in RecyclerView
i. add following to your Activity/Fragment```kotlin
recyclerView.loadCountries { selectedCountry: CPCountry ->
// your code to handle selected country
}
```ii. [Read More](https://github.com/hbb20/AndroidCountryPicker/wiki/Country-List-(RecyclerView)) about Country List and available configuration
### Credits
- [ip2Location](https://www.ip2location.com/) for country data
- Airbnb for [Epoxy Recycler View](https://github.com/airbnb/epoxy) library