问题描述
我有一个简单的Java脚本file.below是我的样本的js code
i have a simple java script file.below is my sample js code
自动播放功能(VIDEOID,ST,EN){
player.loadVideoById({'VIDEOID':VIDEOID,'startSeconds':ST,'endSeconds':恩,'suggestedQuality':'小'});
player.playVideo();
}
function autoplay(videoId, st, en) { player.loadVideoById({ 'videoId': videoId, 'startSeconds': st, 'endSeconds': en, 'suggestedQuality': 'small' }); player.playVideo(); }
function getState(){
alert(player.getPlayerState());
return player.getPlayerState();
}
function CallTweak()
{
alert(player.getPlayerState());
document.getElementById("mytext").innerHTML = player.getPlayerState();
var data=player.getPlayerState();
AndroidFunction.showToast(data);
alert('second alert');
}
我调用一个函数,它工作正常,但我试图调用,例如自动播放()和CallTweak()不叫这些方法两种功能。
下面是样本code调用函数
i calling one function it works fine but i am trying to call two functions for example autoplay() and CallTweak() those methods are not called.below is sample code for calling the functions
web_view.loadUrl(JavaScript的:CallTweak());
web_view.loadUrl(JavaScript的:自动播放());
web_view.loadUrl("javascript:CallTweak()");web_view.loadUrl("javascript:autoplay()");
如何在同一时间在一个单一的按一下按钮在Android中调用多个函数?先谢谢了。
How to call more than one function at a time in a single button click in android?Thanks in advance.
推荐答案
取两种方法之一
无论哪种,在你的JavaScript code,确定了第三函数,它们调用其他两个
Either, in your javascript code, define a third function which calls the other two
function callBothFunctions(){
CallTweak();
autoplay();
}
然后再调用第三个功能
and then call that third function
web_view.loadUrl("javascript:callBothFunctions()");
或,另一种方法是使用像
Or, the other approach is to use an anonymous self-executing function like
string javascriptFunctionCall =
"javascript:"
+ "(function(){"
+ "CallTweak();"
+ "autoplay();"
+"})()";
web_view.loadUrl(javascriptFunctionCall);
这篇关于如何在android系统调用多个Java脚本函数更以时间来加载web视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!