AutoCompleteTextView no muestra ningún elemento desplegable

Mi XML:

<AutoCompleteTextView android:id="@+id/searchAutoCompleteTextView_feed" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:completionThreshold="2" android:hint="@string/search" /> 

MI código java:

 AutoCompleteTextView eT = (AutoCompleteTextView)findViewById(R.id.searchAutoCompleteTextView_feed); eT.addTextChangedListener(this); String[] sa = new String[]{"apple", "mango", "banana", "apple mango", "mango banana"}; ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, sa); eT.setAdapter(aAdapter); 

Esto no está funcionando atall …. quiero decir su sólo funciona como un EditTextView. ¿Dónde estoy equivocado?

Código completo:

 public class FeedListViewActivity extends ListActivity implements TextWatcher{ private AutoCompleteTextView eT; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.feed); eT = (AutoCompleteTextView) findViewById(R.id.searchAutoCompleteTextView_feed); eT.addTextChangedListener(this); Thread thread = new Thread(null, loadMoreListItems); thread.start(); } private Runnable returnRes = new Runnable() { public void run() { //code for other purposes } }; private Runnable loadMoreListItems = new Runnable() { public void run() { getProductNames(); // Done! now continue on the UI thread runOnUiThread(returnRes); } }; protected void getProductNames() { String[] sa = new String[]{"apple", "mango", "banana", "apple mango", "mango banana"}; ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_dropdown_item_1line, sa); eT.setAdapter(aAdapter); } public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } } 

Acabo de ver tu otra pregunta antes de ver esta. Yo estaba luchando con autocompletar durante algún tiempo y casi se volvió a su nueva aplicación de descarga de todas las palabras clave hasta que finalmente conseguí que funcione. Lo que hice fue;

 //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); 

En el método onTextChanged de mi textwatcher, obtengo el sugiere usar un asynctask

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

En el método onPostExecute de AsyncTask, actualizo la 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(); 

Consulte setNotifyOnChange y notifyDataSetChanged para obtener más información

  AutoCompleteTextView eT = (AutoCompleteTextView)findViewById(R.id.searchAutoCompleteTextView_feed); // eT.addTextChangedListener(this); String[] sa = new String[]{"apple", "mango", "banana", "apple mango", "mango banana"}; ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, sa); eT.setAdapter(aAdapter); 

Su trabajo sólo comentario sobre et.addtext línea …

Esto es un fragmento de mi proyecto. Creo que después de obtener los datos de los servicios todo lo que tienes que hacer es:

  1. Borrar los datos anteriores.
  2. Borrar los valores del adaptador anterior.
  3. A continuación, agregue valores a su lista de datos mediante el método add () o addAll ().
  4. Notifique los datos cambiados llamando a notifyDataSetChanged () en el adaptador.

     @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(); 

    }

Pero antes de todo esto asegúrese de que ha conectado el adaptador a la auto texto completo si no lo hacen de la siguiente manera:

 ArrayAdapter<String> stringArrayAdapterPatient= new ArrayAdapter<String>(getActivity(),android.support.v7.appcompat.R.layout.select_dialog_item_material,stringArrayListPatients); completeTextViewPatient.setAdapter(stringArrayAdapterPatient); 
  • Cómo agregar el oyente a autocompletetextview, android?
  • Cómo crear personalizado BaseAdapter para AutoCompleteTextView
  • Configuración de varios elementos personalizados en MultiAutoCompleteTextView: Android
  • Cómo Agregar y eliminar las burbujas de contacto correctamente en multiautocompletetextview con espacio tokenizer como gmail al campo en android
  • Falta el diccionario predeterminado en AutoCompleteTextView / MultiAutoCompleteTextView
  • AutoCompleteTextView no muestra el menú desplegable cuando presiono espacio después de escribir una palabra completa
  • Sugerencia de float de AutoCompleteTextView
  • AutoCompleteTextView recorta la última fila
  • Eliminar AutoCompleteTextView lista desplegable divider
  • Crash con Android 4.1 con ArrayMap
  • Cómo obtener el ID correcto del adaptador AutoCompleteTextView
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.