Disable Android AutoCompleteTextView after user selects item from drop down

magneticMonster picture magneticMonster · Nov 8, 2011 · Viewed 19.9k times · Source

I'm using Android's AutoCompleteTextView with a CursorAdapter to add autocomplete to an app. In the view's onItemClickListener() (i.e. when the user touches one of the autocompleted drop down items) I retrieve the text and place it in the EditText so that the user can modify it if they need to.

However, when I call setText() on the TextView the autocomplete behavior is triggered and the dropdown shows again. I'd like to only show the dropdown if the user types new text with the keyboard. Is there a way to do this?

Answer

Franziskus Karsunke picture Franziskus Karsunke · Nov 8, 2011

You can use the dismissDropDown() method of the AutoCompleteTextView object. Take a look at the documentation.