Last active
July 27, 2017 04:05
-
-
Save gauravrai1/b144dec60808724a116bee8e12267aad to your computer and use it in GitHub Desktop.
Snippet for AutoCompleteView (Android)
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
String[] cities = { "Mumbai","Chennai","Delhi","Banglore","Kolkata","Nagpur","Pune","Nashik","Ahemdabad","Vadodara","Kochin"}; | |
ArrayAdapter<String> adaptercity = new ArrayAdapter<String>(this,android.R.layout.select_dialog_singlechoice, cities); //pass our array of string | |
AutoCompleteTextView acTextViewcity = (AutoCompleteTextView) findViewById(R.id.city);//initialize your view | |
acTextViewcity.setThreshold(1);//set the number of element to be choosen | |
acTextViewcity.setAdapter(adaptercity); //set the array within the adapter here | |
//custom names used to explain the code: cities,adaptercity,acTextViewcityand all the city names. |
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
<AutoCompleteTextView | |
//attributes almost same as EditText | |
android:id="@+id/city" | |
android:layout_width="352dp" | |
android:layout_height="45dp" | |
android:background="@drawable/roundborder" | |
android:hint="City/Town" | |
android:inputType="text" | |
android:paddingLeft="20dp" | |
android:textColor="#ffffff" | |
android:textColorHint="#e0e0e0" | |
android:textStyle="bold" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment