I want my EditText should work as AutoComplete, for that I write in XML file
android:inputType="textAutoComplete|textAutoCorrect" but it's not working.
I am working with API v2.2 and my Activity extends MapActivity, there I put a simple EditText and a button named "Search". so if we type the location name in EditText and press search button means it should go to that location in map. So I want that EditText to work as a AutoComplete. How can I do that?
Just use an AutoCompleteTextView instead of normal EditText.
hello-autocomplete will be helpful.
EDIT: The above link looks like has expired. The new page is here: https://developer.android.com/training/keyboard-input/style#AutoComplete
First convert your EditText->AutoCompleteTextView
Then link your XML file to the AutoCompleteTextView using a ArrayAdapter
Assume that the XML string-array you created is named as list_of_countries then it can be linked to your AutoCompleteTextView as follows:
String[] countries = getResources().getStringArray(R.array.list_of_countries); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,countries); actv.setAdapter(adapter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With