CountryPicker

Additional

Language
Java
Version
N/A
Created
Dec 15, 2015
Updated
Apr 23, 2016 (Retired)
Owner
Juan Pablo Prado (juanpabloprado)
Contributors
Juan Pablo Prado (juanpabloprado)
Denis Sermukhamedov (dmedov)
2
Activity
Badge
Generate
Download
Source code

CountryPicker

CountryPicker is an Android library created to show a custom fragment which allows to choose a country.

Screenshots

Installation

Add CountryPicker dependency to your build.gradle

dependencies {
  compile 'com.juanpabloprado:countrypicker:1.2.0'
}

Or add CountryPicker as a new dependency inside your pom.xml

<dependency>
  <groupId>com.juanpabloprado</groupId>
  <artifactId>countrypicker</artifactId>
  <version>1.2.0</version>
  <type>aar</type>
</dependency>

How to use

To embed CountryPicker in your own activity:

getSupportFragmentManager().beginTransaction()
        .replace(R.id.container,
            CountryPicker.getInstance(new CountryPickerListener() {
              @Override public void onSelectCountry(String name, String code) {
                Toast.makeText(MainActivity.this, "Name: " + name, Toast.LENGTH_SHORT).show();
              }
            }))
        .commit();

To show CountryPicker as a dialog:

CountryPicker picker = CountryPicker.getInstance("Select Country", new CountryPickerListener() {
  @Override public void onSelectCountry(String name, String code) {
    Toast.makeText(getActivity(), "Name: " + name, Toast.LENGTH_SHORT).show();
    DialogFragment dialogFragment =
        (DialogFragment) getSupportFragmentManager().findFragmentByTag("CountryPicker");
    dialogFragment.dismiss();
  }
});
picker.show(getSupportFragmentManager(), "CountryPicker");

Developed By

License

Copyright 2015 Juan Pablo Prado

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.