In this blog, I will tell you how you can easily make county code Spinner in the Android App. It's like a spinner selector.
I know its a common think you can make it easier but it can take so much time to collect all country name with their flag and then make a custom adapter then set that adapter to you spinner rather than this you can use this easy method which I have given below.
First of all, I am giving the link of library-ClickMe
this is the country code picker library you can see the procedure in official git page or you can work with me.
1.implement below lines in Gradle file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.hbb20:ccp:2.3.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.hbb20.CountryCodePicker | |
android:id="@+id/et1" | |
android:layout_width="0dp" | |
android:layout_height="41dp" | |
android:layout_marginStart="50dp" | |
android:layout_marginTop="56dp" | |
android:layout_marginEnd="50dp" | |
android:background="@drawable/inputlayout" | |
android:gravity="center" | |
app:ccp_contentColor="@color/color2" | |
app:ccp_textSize="14sp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintHorizontal_bias="1.0" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var countrycd=et1.selectedCountryCodeWithPlus.toString() |
Source Code-ClckMe
0 Comments