AutoCompleteTextView with server response

How to create an AutoCompleteTextView that will receive results from a remote server?

As I understand it, I need to implement an ArrayAdapter, which should make asynchronous requests to the server.

+5
source share
2 answers

1) You must first create a class for asyncTask, and you must establish a connection to the remote server in the doInBackground () method

2) you must make an arrayAdapter from the remoteServer response, this also needs to be done in the doInBackground () method

3) after successful installation of the adapter in AutoCompleteTextView

new AsyncTask<Integer, Void, arrayList> () {
    ProgressDialog progressDialog;

    @Override
    protected void onPreExecute() {
        progressDialog = ProgressDialog.show(context, "downloading...", "Please wait...");
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(arrayList result) {
        //make arrayAdapter from result
        //set adapter to AutoCompleteTextView
        progressDialog.dismiss();
        super.onPostExecute(result);
    }

    @Override
    protected arrayList doInBackground(Integer... params) {
        // make connection to remote server
        //retrive response from remote server
        // make arrayList from response

        return arrayList
    }
}.execute(1);
+3
source

AutoCompleteTextView I am not intended for this kind of action, I once thought like you, and made very bad code with this ...

, , EditText listView, .

, 100-130 , , , , , .

, .

.

AutoCompleteTextview . AsyncTask , , , ...

+6

All Articles