Search code examples
listviewautocompletebreakpointsautocompletetextview

Android-Dev: AutoCompleteTextView only showing last entry


as in tutorials shown, I've created an AutoCompleteTextView and I connected it with an ArrayAdapter filled with a dummy Array ({"Android","Enter","Entertainment"}).

If I test the AutoCompleteTextView following errornous behaviour is noticed:

  1. Typing "E" or "e" -> only suggestion "Entertainment" is shown. Usually, both "Entertainment" AND "Enter" should be shown.
  2. Typing "A" or "a" -> no suggestion at all is shown. Usually, suggestion "Android" should be shown.

It looks like only the last string entry is added as a suggestion. What could be the problem? This is my code within an Activity class:

private static final String[] DUMMY_ENTRIES = new String[] {"Android","Enter","Entertainment"};

private void setAutoCompleteField() {
    mSearchView = (AutoCompleteTextView) findViewById(R.id.search_mac);

    mSearchView.setHintTextColor(Color.WHITE);
    mSearchView.setTextColor(Color.WHITE);
    mSearchView.setHint("Nach Essen suchen ...");

    mSearchView.setThreshold(1);

    ArrayAdapter<String> adp = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, DUMMY_ENTRIES);
    mSearchView.setAdapter(adp);
}

Solution

  • Well I found one solution, that is, I simply upgraded my Android 4.2.2 to Android 5.0. Now it works, but I don't know why. The AutoCompleteTextView should be working on 4.2.2..