0

I made a android webview app using the following code

        webView = (WebView) findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());


        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webView.loadUrl("*web url*");

the problem is that some forms in the webpage functions correctly but there are some forms that when I click on it, it automatically closes the keyboard therefore not allowing the user to type anything? any fix on this?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Reub
  • 121
  • 2
  • 13

1 Answers1

0

Try to add requestFocus to your WebView like this:

webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setUseWideViewPort(true);
webview.requestFocus(View.FOCUS_DOWN);

Also try to alter windowSoftInputMode by reading the official documentation here

  • the solution didnt work. still closes the keyboard automatically – Reub Aug 09 '18 at 07:41
  • does the keyboard open again when you click in EditText or TextField though? @Reub – ThomasLothbrok Aug 09 '18 at 07:46
  • *also there is a navigation icon that doesnt work as well (hamburger icon). – Reub Aug 09 '18 at 07:47
  • Try to add onTouchListener to your webView : `webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: v.requestFocusFromTouch(); break; } return false; } });` @Reub – ThomasLothbrok Aug 09 '18 at 08:04
  • I cant scroll down. i think something is missing? – Reub Aug 09 '18 at 08:07
  • does it respond to your clicks now though @Reub? – ThomasLothbrok Aug 09 '18 at 08:08
  • not yet. i cannot scroll down to the portion of the page that I need. seems the code keeps on scrolling the page up – Reub Aug 09 '18 at 08:09
  • have you tried loading different web page? @Reub, also make sure you have set the view orientation to vertical beforehand. – ThomasLothbrok Aug 09 '18 at 08:13
  • there is a form that works that redirects me to that page with another form where the error occurs. the previous page's form was working correctly – Reub Aug 09 '18 at 08:14
  • Very interesting, your first page works. Try to clear the cache and history as I assume your webView is still holding its reference to the first page? @Reub `webView.clearCache(true); webView.clearHistory();` , – ThomasLothbrok Aug 09 '18 at 08:34
  • still not working. any idea about the navigation (hamburger logo)? doesnt seem to work when I click on it. – Reub Aug 09 '18 at 08:37
  • do you know what this means? Autofill suggestions are disabled because the document isn't a secure context or the form's action attribute isn't secure. this seems to popup in the logcat every time I click on that form – Reub Aug 10 '18 at 01:16
  • Sorry for late reply, in my opinion it might have something to do with http or https protocol ? – ThomasLothbrok Aug 10 '18 at 02:15
  • looks like the problem is with the windows.resize as described here. https://stackoverflow.com/questions/14854359/android-html-input-loses-focus-when-soft-keyboard-opens-asp-net – Reub Aug 10 '18 at 03:44
  • Looks like you have to tweak the web code doesn't it? It is solved now though? Good luck mate – ThomasLothbrok Aug 11 '18 at 03:42
  • yea we were able to fix it. just removed some part of the css. thanks btw. the only thing left to solve is the hamburger icon not working in webview. – Reub Aug 13 '18 at 00:02