Creating a spinner for choosing country code

后端 未结 3 1749
生来不讨喜
生来不讨喜 2020-12-30 11:45

I want to create a spinner for selecting a country and getting its country code.

I already found this item list:



        
3条回答
  •  误落风尘
    2020-12-30 12:34

    in gradle :

        // country picker
        implementation 'com.hbb20:ccp:1.7.1'
    

    in XML

    
    

    in Activity :

    CountryCodePicker ccp;
    ccp = findViewById(R.id.ccp);
        public void onCountryPickerClick(View view) {
            ccp.setOnCountryChangeListener(new CountryCodePicker.OnCountryChangeListener() {
                @Override
                public void onCountrySelected() {
                    //Alert.showMessage(RegistrationActivity.this, ccp.getSelectedCountryCodeWithPlus());
                    selected_country_code = ccp.getSelectedCountryCodeWithPlus();
                }
            });
        }
    

提交回复
热议问题