Creating a spinner for choosing country code

后端 未结 3 1750
生来不讨喜
生来不讨喜 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:25

    I have a cleaner solution for you. You can use Country Code Picker (CCP) library directly.It will save you from boilerplate code. You just need to place the CountryCodePicker view in your layout XML. This is CCP view .

    Your view will look like with your phone editText.

    Download Sample application from PlayStore.

    Clicking on CCP will open a dialog with a list of country to select from. Here you can search country with country name, code name, phone code. It also gives an option to autoformat phone number.

    Selected country details can be read easily. For more details go to Library's Github page.

提交回复
热议问题