Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoCompleteTextView with server response

Tags:

android

How to create AutoCompleteTextView which will fetch results from remote server?

As I understand I need to implement ArrayAdapter, which must make async requests to server.

like image 916
skywa1ker Avatar asked Apr 21 '11 06:04

skywa1ker


1 Answers

AutoCompleteTextView i not meant for this kind of action, i once thought like you and made very bad code with that...

if your auto complete list comes from he network based on every character you input, you better off create a Vertical Linear Layout which contains an EditText and a listView, and create a connection pool.

for every key type check if it was typed in 100-130 ms to make sure the user is likely to wait for a response and issue a request, on any new request, remove or invalidate the last request u've sent.

one response safely arrives , update your list adapter.

works smoothly for me.

AutoCompleteTextview uses a pre made list. it uses AsyncTask itself so i'ts pretty bad to use one yourself to update the list it uses...

like image 124
codeScriber Avatar answered Nov 11 '22 16:11

codeScriber