lamudi-gmbh / android-phone-field

A small library that allows you to create phone fields with corresponding country flags, and validate the phone number using libphonenumber from google.
Apache License 2.0
227 stars 67 forks source link

Limit the Country list #11

Open OmarAhmed193 opened 6 years ago

OmarAhmed193 commented 6 years ago

Is there's a way to limit the country listing to specific countries?

hamedkh29 commented 6 years ago

You can change country list by inheritance as following:

public class PhoneField extends PhoneInputLayout { public PhoneField(Context context, AttributeSet attrs) { super(context, attrs); int skipCounter = 0; int countrySize = Countries.COUNTRIES.size(); for(int i=0;i<countrySize;i++) { Countries.COUNTRIES.remove(0); } Countries.COUNTRIES.add(new Country("dk", "Denmark (Danmark)", 45)); Countries.COUNTRIES.add(new Country("se", "Sweden (Sverige)", 46)); } }

Good Job!