Android: AutoCompleteTextView hide soft keyboard

Use OnItemClickListener. Hope this works :)

AutoCompleteTextView text = (AutoCompleteTextView) findViewById(R.id.auto_insert_meds);

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);

  }

});

UPDATED

Use this

in.hideSoftInputFromWindow(arg1.getApplicationWindowToken(), 0);

instead of -

in.hideSoftInputFromWindow(arg1.getWindowToken(), 0);

1) Change AutoCompleteTextView dropdown height to MATCH_PARENT

setDropDownHeight(LinearLayout.LayoutParams.MATCH_PARENT);

2) Dismiss soft keyboard by overriding getView() of AutoCompleteTextView adapter

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View v = super.getView(position, convertView, parent);
    v.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(
                                Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(
                        typeTextView.getWindowToken(), 0);
            }

            return false;
        }
    });

    return v;
}

As chakri Reddy Suggested:

It's working for me I just replaced

this:

 in.hideSoftInputFromWindow(arg1.getWindowToken(), 0);

with:

 in.hideSoftInputFromWindow(arg1.getApplicationWindowToken(), 0);

Found this chunk of code in a similar thread. Hope it helps:

    private void hideKeyboard() {   
        // Check if no view has focus:
        View view = this.getCurrentFocus();
        if (view != null) {
            InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
}

Link to the original post. Note that it is not the accepted answer.