0

Есть EditText. Вот его код:

        <EditText
        android:id="@+id/editSearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint = "Поиск"
        android:textColorHint="#c0c0c0"
        android:textColor="#fff"
        android:paddingRight="22dp"
        android:paddingLeft="8dp"
        android:paddingTop="13dp"
        android:drawableRight="@drawable/search"
        android:paddingBottom="16dp"
        android:imeOptions="actionSearch"
        android:inputType="text"
        android:maxLines="1"
        android:layout_toEndOf="@+id/backButton" />

Вызываем клавиатуру, что-то вводим, тыкаем кнопку поиск (imeOptions = "actionSearch"),фокус с edittext пропадает, а клавиатура меняется на обычную(с кнопкой enter, а не поиск), вместо того чтобы пропасть. Почему так происходит и как это исправить?

1 ответ 1

0

попробуй подвесить это на actionSearch

public static void hideSoftKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        if (inputMethodManager != null)
            if (activity.getCurrentFocus() != null)
                if (activity.getCurrentFocus().getWindowToken() != null)
                    inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.