Android: Autocomplete TextView Similar To The Facebook App

First make your EditText into a MultiAutoCompleteTextView. A MultiAutoCompleteTextView allows you to replace certain parts of the text, for example text after ‘@’. The you can do something like this: final MultiAutoCompleteTextView inputEditText = (MultiAutoCompleteTextView) dialog.findViewById(R.id.MyEditText); String[] COUNTRIES = new String[] { “Belgium”, “France”, “Italy”, “Germany”, “Spain” }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES); … Read more

AutoCompleteTextView not completing words inside parentheses

An answer, provided by @BNK, is correct. However, I would like to give a similar solution, which doesn’t require the whole ArrayAdapter class file. Instead, we will just extend that class and override its only 2 methods: getView() and getFilter(). So, define your AutoSuggestAdapter class: import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; … Read more

How do I Use AutoCompleteTextView and populate it with data from a web API?

I came up with a solution, I don’t know if it is the best solution, but it appears to work very well. What I did was created a custom adapter that extends ArrayAdapter. In the custom adapter I overrode getFilter and created my own Filter class that overrides performFiltering. This starts a new thread so … Read more

How to create custom BaseAdapter for AutoCompleteTextView

The following is my working code using ArrayAdapter. Let’s assume the reponse data from web service looks like the following: [ { “id”: “1”, “name”: “Information Technology” }, { “id”: “2”, “name”: “Human Resources” }, { “id”: “3”, “name”: “Marketing and PR” }, { “id”: “4”, “name”: “Research and Developement” } ] Then in your … Read more

Android AutoCompleteTextView with Custom Adapter filtering not working

I have to over-ride the getFilter() method of the Adapter Here is the code which worked for me, thanks to sacoskun public class CustomerAdapter extends ArrayAdapter<Customer> { private final String MY_DEBUG_TAG = “CustomerAdapter”; private ArrayList<Customer> items; private ArrayList<Customer> itemsAll; private ArrayList<Customer> suggestions; private int viewResourceId; public CustomerAdapter(Context context, int viewResourceId, ArrayList<Customer> items) { super(context, viewResourceId, … Read more

AutoCompleteTextView backed by CursorLoader

Basically, androids autocomplete textview is not very powerful, when I have to deal with bigger amounts of data, what I do is, i keep a text change listener to the edit text for search, and then whenever something is changed on the edit text, it queries database. If this might help someone, placing an edittext … Read more

How to dynamically add suggestions to autocompletetextview with preserving character status

one of the easiest way of doing that (put the code in onCreate): EDIT: addied wikipedia free opensearch (if https://en.wikipedia.org doesn’t work try http://en.wikipedia.org) AutoCompleteTextView actv = new AutoCompleteTextView(this); actv.setThreshold(1); String[] from = { “name”, “description” }; int[] to = { android.R.id.text1, android.R.id.text2 }; SimpleCursorAdapter a = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, null, from, to, 0); a.setStringConversionColumn(1); … Read more