简体   繁体   English

无法在WebView中键入内容

[英]Can't type inside a WebView

I have a problem interacting with a WebView . 我在与WebView交互时遇到问题。 I'm showing an HTML login form within a WebView and I can't type inside of any of the input fields of the forms. 我在WebView显示HTML登录表单,我无法在表单的任何输入字段内输入。 I do can interact with the links, select boxes, buttons, etc. 我可以与链接,选择框,按钮等进行交互。

Here is an example of my code. 这是我的代码示例。 Basically I'm retrieving the web view from the xml and setting it a WebViewClient and a WebChromeClient . 基本上我正在从xml中检索Web视图并将其设置为WebViewClientWebChromeClient

webview = (WebView) findViewById(R.id.loginWebview);
webview.getSettings().setJavaScriptEnabled(true);

WebViewClient client = new WebViewClient();
webview.setWebViewClient(client);

webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl("http://www.google.com");

Any ideas? 有任何想法吗?

You can do the following to solve this: 您可以执行以下操作来解决此问题:

WebView webView = (WebView)findViewById(R.id.yourWebView);
webView.getSettings().setJavaScriptEnabled(true);
webView.requestFocus(View.FOCUS_DOWN);

There is another post here . 还有另一篇文章在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM