Frage

There are a lot of questions about how to display Soft Keyboard in android WebView. I have a problem quite opposite of that.

For some reason the Soft Keyboard keeps showing up every time I click anything (just some text for example) in the WebView content. There are no input fields in the view, nor are there any EditText elements.

This problem exists only when using Android 4.3 (not an issue with older versions or with 4.4).

I have tried most of the solutions I have found and the only way I can get that thing to not appear is using

android:focusableInTouchMode="false" 

in the layout file.

That causes other problems though - now if I add a select field to the HTML file in WebView window - after selection is made an error is produced and focus does not return to the webview (so can't use it any more after that).

01-07 10:59:49.848: W/InputMethodManagerService(287): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41a0b510 attribute=null, token = android.os.BinderProxy@41771d70

War es hilfreich?

Lösung

Found a solution. Pretty weird one. I removed the focusableInTouchMode thing from the layout definition and added this to JavaScript in my WebView content:

document.addEventListener('click',function() { 
  document.activeElement.blur(); 
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top