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
A kind of hack solution which came to my mind but still does what is required - hides the keyboard so user will not see it:
public class WebViewEx extends WebView {
private Handler mHandler;
@Override
public boolean onTouchEvent(MotionEvent event) {
ensureKeyboard();
return super.onTouchEvent(event);
}
private void ensureKeyboard() {
if(mHandler == null){
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
closeKeyboard();
sendEmptyMessageDelayed(0, 10);
}
};
}
mHandler.removeCallbacksAndMessages(null);
mHandler.sendEmptyMessage(0);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mHandler.removeCallbacksAndMessages(null);
}
}, 300);
}
private void closeKeyboard() {
InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
}
}
Feel free to play with the delays to minimize overhead because of rapid call of a function during the predefined period. I believe optimal values may vary depending on device.