Java 以编程方式将文本插入webview中的文本字段

Java 以编程方式将文本插入webview中的文本字段,java,android,android-webview,Java,Android,Android Webview,我有一个web视图,我想在其中插入一些文本(如自动填充功能)。有什么办法吗?我尝试使用java脚本 document.execCommand('insertHTML', false,text ); 但它不起作用。您需要使用android提供的javascript接口机制 WebView webView = (WebView) findViewById(R.id.webview); WebSettings webSettings = myWebView.getSettings(); webSet

我有一个web视图,我想在其中插入一些文本(如自动填充功能)。有什么办法吗?我尝试使用java脚本

document.execCommand('insertHTML', false,text );

但它不起作用。

您需要使用android提供的javascript接口机制

WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.loadUrl("javascript://your_javascrpit_method");
希望是工作: