Android WebView,评估JutuateJavaScript并将值作为数组获取
我正在尝试使用WebView.evaluatejavascript方法获得JavaScript结果。我可以将返回值作为字符串类型获取。当我将变量类型从字符串更改为字符串[]时,它会自动生成此代码行
(valueCallback)新的valueCallback< string []>()。
public void getDataFromJs(String command, WebView webView) {
webView.evaluateJavascript("(function() {" + command + "; })();", (ValueCallback<String>) new ValueCallback<String[]>() {
@Override
public void onReceiveValue(String[] s) {
MyList=s.clone();
}
});
错误:不兼容的类型:&lt;匿名valueCallback&lt; string []&gt;&gt;无法转换为ValueCallback
I am trying to get javascript results using webView.evaluateJavascript method. I can get the return value as type of string. When i changed the variable type from String to String[], it automatically generates this line of code
(ValueCallback) new ValueCallback<String[]>().
public void getDataFromJs(String command, WebView webView) {
webView.evaluateJavascript("(function() {" + command + "; })();", (ValueCallback<String>) new ValueCallback<String[]>() {
@Override
public void onReceiveValue(String[] s) {
MyList=s.clone();
}
});
error: incompatible types: <anonymous ValueCallback<String[]>> cannot be converted to ValueCallback
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您必须更改这样的签名:
webview.evaluatejavascript(“(”(function(){“ + command +”;})()();“,(valueCallback&lt; string []&gt;)new new valueCallback&lt; string [ ]&gt;(){}
I think you must change the signature like this :
webView.evaluateJavascript("(function() {" + command + "; })();", (ValueCallback<String[]>) new ValueCallback<String[]>() {}