I've created an Android app that uses the Google Places AutoCompleteTextView which successfully lists the predictions. However, when a user has selected the prediction that they are looking for, the keyboard doesn't hide (Same for when a user presses enter or finish on the keyboard). How easy is to to hide the keyboard once a user has selected one of the Google predictions?
Asked
Active
Viewed 55 times
0
-
1Strange, as my AutocCompleteTextViews usually close the keyboard upon selection. I guess you can do a myTextView.setOnItemSelectedListener( //do stuff to close keyboard). – Noel Bautista May 01 '15 at 15:03
-
Hmm... Well... This is what I currently have. There may be an issue with they way that I implemented it or something: http://pastebin.com/44QBuKXd – Luke Willmer May 01 '15 at 15:34
1 Answers
1
@DERPA_CHIEF You were correct! The code necessary to add was:
autoCompView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(autoCompView.getWindowToken(), 0);
}
});

Luke Willmer
- 327
- 2
- 6
- 14