我有一个 Web View ,我想在其中插入一些文本(例如自动填充功能)。有什么办法吗?我尝试使用 java 脚本。
document.execCommand('insertHTML', false,text );
但是没有用。
最佳答案
你需要使用android提供的javascript接口(interface)机制。
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.loadUrl("javascript://your_javascrpit_method");
关于java - 以编程方式将文本插入到 webview 中的文本字段中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22148089/