@@ -0,0 +1,2552 @@
+package com.msg91.axay.sendotp;%0A%0Aimport android.content.Context;%0Aimport android.util.AttributeSet;%0Aimport android.view.View;%0Aimport android.widget.AdapterView;%0Aimport android.widget.ArrayAdapter;%0Aimport android.widget.Spinner;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Locale;%0Aimport java.util.Map;%0Aimport java.util.TreeMap;%0A%0A/**%0A * @author akshay%0A * @since 13/4/16%0A */%0Apublic class CountrySpinner extends Spinner %7B%0A%0A    private Map%3CString, String%3E mCountries = new TreeMap%3C%3E();%0A    private List%3CCountryIsoSelectedListener%3E mListeners = new ArrayList%3C%3E();%0A%0A    public interface CountryIsoSelectedListener %7B%0A        void onCountryIsoSelected(String iso);%0A    %7D%0A%0A    public CountrySpinner(Context context) %7B%0A        super(context);%0A    %7D%0A%0A    public CountrySpinner(Context context, AttributeSet attrs) %7B%0A        super(context, attrs);%0A    %7D%0A%0A    public void init(String defaultCountry) %7B%0A        initCountries();%0A        List%3CString%3E countryList = new ArrayList%3C%3E();%0A%0A        countryList.addAll(mCountries.keySet());%0A        countryList.remove(defaultCountry);%0A        countryList.add(0, defaultCountry);%0A%0A        ArrayAdapter adapter = new ArrayAdapter%3C%3E(getContext(), android.R.layout.simple_spinner_item, countryList);%0A%0A        setAdapter(adapter);%0A%0A        setOnItemSelectedListener(new OnItemSelectedListener() %7B%0A            @Override%0A            public void onItemSelected(AdapterView%3C?%3E adapterView, View view, int position, long id) %7B%0A                final String selectedCountry = (String) adapterView.getItemAtPosition(position);%0A                notifyListeners(selectedCountry);%0A            %7D%0A%0A            @Override%0A            public void onNothingSelected(AdapterView%3C?%3E adapterView) %7B%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public void addCountryIsoSelectedListener(CountryIsoSelectedListener listener) %7B%0A        mListeners.add(listener);%0A    %7D%0A%0A    public void removeCountryIsoSelectedListener(CountryIsoSelectedListener listener) %7B%0A        mListeners.remove(listener);%0A    %7D%0A%0A    private void initCountries() %7B%0A        String%5B%5D isoCountryCodes = Locale.getISOCountries();%0A        for (String iso : isoCountryCodes) %7B%0A            String country = new Locale(%22%22, iso).getDisplayCountry();%0A            mCountries.put(country, iso);%0A        %7D%0A    %7D%0A%0A    private void notifyListeners(String selectedCountry) %7B%0A        final String selectedIso = mCountries.get(selectedCountry);%0A        for (CountryIsoSelectedListener listener : mListeners) %7B%0A            listener.onCountryIsoSelected(selectedIso);%0A        %7D%0A    %7D%0A%7D%0A%0A

create CountrySpinner class