无法在WebView中键入 [英] Can't type inside a WebView

查看:95
本文介绍了无法在WebView中键入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WebView交互时遇到问题.我正在显示WebView中的HTML登录表单,并且无法在表单的任何输入字段中键入内容.我可以与链接,选择框,按钮等进行交互.

I have a problem interacting with a 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. I do can interact with the links, select boxes, buttons, etc.

这是我的代码的示例.基本上,我是从xml检索Web视图并将其设置为WebViewClientWebChromeClient.

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.

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");

有什么想法吗?

推荐答案

您可以执行以下操作来解决此问题:

You can do the following to solve this:

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

此处.

这篇关于无法在WebView中键入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆