Disable Android AutoCompleteTextView after user selects item from drop down
If you wish to dissmis AutoCompleteTextView's dropdown you should use its post(Runnable r) method. It works for me :)
Here is an example:
mAutoCompleteTextView.post(new Runnable() {
public void run() {
mAutoCompleteTextView.dismissDropDown();
}
}
You can use the dismissDropDown()
method of the AutoCompleteTextView object. Take a look at the documentation.
When we click on item suggested in AutoCompleteTextView.onTextChanged()
is performed before onItemClick
So, to avoid this try below code..
autocompletetextview.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (autocompletetextview.isPerformingCompletion()) {
// An item has been selected from the list. Ignore.
} else {
// Perform your task here... Like calling web service, Reading data from SQLite database, etc...
}
}
@Override
public void afterTextChanged(final Editable editable) {
}
});