Search code examples
androidautocompletetextview

Soft keyboard not hidden when Done clicked in AutocompleteTextView


I have several EditText in my app, and when the "Done" key is clicked the soft keyboard is hidden. This does not happen with AutocompleteTextView.

Any idea why? Is there anything more to do to get the same behaviour with AutocompleteTextView?

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_below="@id/search_zip"
    android:layout_toLeftOf="@id/submit"
    android:paddingLeft="10dp"
    android:hint="@string/city_or_zip"
    android:background="@drawable/bt_grey"
    android:inputType="text"/>

Solution

  • android:imeOptions="actionDone"
    

    or in java code:

    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);    
    inputManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);