Prevent Buttons From Hiding Soft Keyboard On Android

前端 未结 3 1777
广开言路
广开言路 2020-12-11 03:55

I have a WebView and some buttons in my layout. There is a large tag in my WebView. This app is used to edit text files. The buttons are used to effect the textarea inside

3条回答
  •  庸人自扰
    2020-12-11 04:31

    The solution to your problem might be to keep the keyboard always shown and letting the user to close it when the actions are done.

    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
    inputManager.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    

    Try this code in the onCreate() method of your Activity. Note that if the user presses the close button on the keyboard or the back button it should close it. And I guess you shouldn't interfere with that scenario. And when the actions are done you can then close the keyboard from code.

提交回复
热议问题