在 AutocompleteTextView 中单击“完成”时未隐藏软键盘

Soft keyboard not hidden when Done clicked in AutocompleteTextView

我的应用程序中有几个 EditText,当单击 "Done" 键时,软键盘被隐藏。 AutocompleteTextView.

不会发生这种情况

知道为什么吗?要获得与 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"/>
android:imeOptions="actionDone"

或在java代码中:

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

在我的案例中 setOnEditorActionListener 是个问题。所以我删除了以下代码:

searchEditText?.setOnEditorActionListener { v, actionId, event ->
            if (EditorInfo.IME_ACTION_DONE == actionId) {
                return@setOnEditorActionListener true
            } else
                return@setOnEditorActionListener false
        }