AutoCompleteTextView not showing any drop down items

I just saw your other question before seeing this one. I was struggling with autocomplete for some time and I almost reverted to your new implementation of downloading all the keywords until I finally got it to work. What I did was;

//In the onCreate
//The suggestArray is just a static array with a few keywords
this.suggestAdapter = new ArrayAdapter<String>(this, this.suggestionsView, suggestArray);
//The setNotifyOnChange informs all views attached to the adapter to update themselves 
//if the adapter is changed
this.suggestAdapter.setNotifyOnChange(true);

In my textwatcher's onTextChanged method, I get the suggests using an asynctask

//suggestsThread is an AsyncTask object
suggestsThread.cancel(true);
suggestsThread = new WertAgentThread();
suggestsThread.execute(s.toString());

In the AsyncTask's onPostExecute I then update the autocompletetextview

//suggestions is the result of the http request with the suggestions
this.suggestAdapter = new ArrayAdapter<String>(this, R.layout.suggestions, suggestions);
this.suggestions.setAdapter(this.suggestAdapter);
//notifydatasetchanged forces the dropdown to be shown.
this.suggestAdapter.notifyDataSetChanged();

See setNotifyOnChange and notifyDataSetChanged for more information


this is a snippet from my project. I think after you got data from services all you have to do is to:

  1. clear your previous data.
  2. clear the previous adapter values.
  3. then add values to your list of data using add() or addAll() method.
  4. notify the data changed by calling notifyDataSetChanged() on adapter.

    @Override
    public void onGetPatient(List<PatientSearchModel> patientSearchModelList) {
    
    //here we got the raw data traverse it to get the filtered names data for the suggestions
    
    stringArrayListPatients.clear();
    stringArrayAdapterPatient.clear();
    for (PatientSearchModel patientSearchModel:patientSearchModelList){
    
        if (patientSearchModel.getFullName()!=null){
    
            stringArrayListPatients.add(patientSearchModel.getFullName());
    
        }
    
    }
    
    //update the array adapter for patient search
    stringArrayAdapterPatient.addAll(stringArrayListPatients);
    stringArrayAdapterPatient.notifyDataSetChanged();
    

    }

but before all this make sure you have attached the adapter to the auto complete textview if don't do it as follows:

ArrayAdapter<String> stringArrayAdapterPatient= new ArrayAdapter<String>(getActivity(),android.support.v7.appcompat.R.layout.select_dialog_item_material,stringArrayListPatients);

completeTextViewPatient.setAdapter(stringArrayAdapterPatient);