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

Dynamically updating an AutoCompleteTextView adapter

I didn’t have any luck using adapter.notifyDataSetChanged() when dynamically adding and changing the data in the adapter. In my situation, I was hitting an external api asynchronously and getting a list of completion data periodically. This code clears the adapter, and adds the new data as you’d expect. However, I had to call the getFilter().Filter … 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

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 to implement autocompletetextview with listview?

First create a custom adapter implements filterable: public class MyFilterableAdapter extends BaseAdapter implements Filterable { private Context context; private List<String> items; private List<String> filteredItems; private ItemFilter mFilter = new ItemFilter(); public MyFilterableAdapter(Context context, List<String> items) { //super(context, R.layout.your_row, items); this.context = context; this.items = items; this.filteredItems = items; } @Override public int getCount() { return … 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