The most efficient (in terms of amount of connections) AutoCompleteTextView implementation I found is the DelayAutoCompleteTextView proposed here. However, I think that it can be improved by do not ask for data that you previously asked for. That is, imagine that the AutoCompleteTextView is connected to a web service and retrieves data about a English Dictionary. Then, if the user writes "Egg", the AutoCompleteTextView will ask to the web service for words containing "Egg" like ["Egg", "Egg-head", "Egged", "Egging", "Eggs", ...] and this list is the one will be showed to the user. Nevertheless, if the user refines the query by typing one more letter (i.e., "Eggi"), the AutoCompleteTextView will ask 'again' to the web server for words containing "Eggi" and here is what I think that can be improved. Why do we need to ask to the web service for information we already have? Words containing "Eggi" are included in the ones containing "Egg" so there is no need to ask to the server, instead we must filter the first list we get from the web service.
Does anyone know how to do this?
Thank you!
I have a possible solution to this. Maybe it can be improved (could anyone think in a better approach?)
The following code (inspired by this) is an Adapter that implements Filterable. The new part is inside getFilter method where I check if the filter constraint is more restrictive than the previous one. If this is the case I don't want to ask to the webservice since the information is already in the resultList obtained previously by asking the webservice with the previous constrint, which was less restrictive.
Please if you know how to do this better let me know.