The picture shows a part of my app, an AutoCompleteTextView
with an attached adapter.
When the user enters something into that view, autocomplete suggestions are shown.
The problem I have is: when the suggestions are shown and the device's down arrow is pressed, only the suggestions from the AutoCompleteTextView
are closed, the keyboard stays open and needs a second tap on the down arrow to disappear.
I do want the suggestions and the keyboard to disappear on the first tap on the down arrow.
I tried overriding onBackPressed
but it is not called when the down arrow is tapped, presumably because it's not considered 'back'.
How could I do this?
EDIT: I know how to programmatically hide the keyboard, I guess my problem is to detect the 'down arrow' tap.
Try to override onKeyPreIme()
method in your AutoCompleteTextView as follows:
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == 1) {
super.onKeyPreIme(keyCode, event);
hideKeyboard()
return true;
}
return super.onKeyPreIme(keyCode, event);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With