Reputation: 103
I follow the below tutorial and successfully implement autocomplete edit textbox and show all the suggestions as item list. I want to hide softkeyboard whenever I touch the item list and that option goes to the edit textbox.
http://www.claytical.com/blog/android-dynamic-autocompletion-using-google-places-api#comment-form
I tried number of options but nothing works. How can I achieve this and implement in an app?
Upvotes: 3
Views: 3467
Reputation: 21551
It's working for me I just replaced
this:
in.hideSoftInputFromWindow(arg1.getWindowToken(), 0);
with:
in.hideSoftInputFromWindow(arg1.getApplicationWindowToken(), 0);
Upvotes: 5
Reputation: 4037
So once you click on one of the autocomplete suggestions and you want the softkeyboard to hide... you need to implement an onClickListener on the selected autocomplete option so that is can hide the soft keyboard as soon as you make a selection after clicking that one.
Create an instance of the autocompleteTextView
AutoCompleteTextView text = (AutoCompleteTextView) findViewById(R.id.resource);
Implement onClicklistener
to hide the soft keyboard using the InputManager.
text.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
in.hideSoftInputFromWindow(arg1.getWindowToken(), 0);
}
});
Hope this Helps!!
Upvotes: 1