How disable softkeyboard in WebView

后端 未结 6 676
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 12:26

I need disable open softkeyboard in my WebView and in all edittexts in WebView (I do not access to thay because its is in WebView).

I try use \'android:windowSoftInp

6条回答
  •  误落风尘
    2020-12-06 12:47

    For the keyboard hidden state:

    public void hideSoftKeyboard(View v) {
                Activity activity = (Activity) v.getContext();
                InputMethodManager inputMethodManager = (InputMethodManager)  activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
                inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
            }
    

    To disable the EditTexts:

    Set android:editable="false" in the layout of them EditText.setFocusable(false) in the activity.

    EDIT:

    To detect the click event in the WebView use this:

     mWebView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                // The code of the hiding goest here, just call hideSoftKeyboard(View v);
                return false;  
                }     
            }); 
    

提交回复
热议问题