Android's webview keyboard does not disappear

Asked 1 months ago, Updated 1 months ago, 4 views
I wrote the code as per the above site, but when I see it in the emulator, the keyboard appears by default, and it doesn't disappear even if I unfocus the edit text.
How do I hide my keyboard?

android java android-studio webview

2022-09-30 11:44

1 Answers

To hide the soft keyboard, you must write the code you want to hide when the user hides the or app is out of focus (for example).

For example, a listener who hides the keyboard when the focus is off will write:

View.OnFocusChangeListener focusLostSoftKeyboardHide=newView.OnFocusChangeListener(){
    @ Override
    public void onFocusChange (View view, boolean hasFocus) {
            InputMethodManager imm=(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

2022-09-30 11:44

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.