0
您好我成功的HTML按鈕單擊事件在Android的webview side.its工作正常時,我的HTML文件內的Android資產文件夾,但當我已經使用HTML頁面在線URL這是說Android的關鍵字不是在Javascript代碼中找到。這裏是我的代碼Html按鈕點擊事件檢測在Android的webview
//webview android addJavascriptInterface
webView.addJavascriptInterface(new WebAppInterface(this), "Android");
public class WebAppInterface {
Context mContext;
WebAppInterface(Context c) {
mContext = c;
}
@JavascriptInterface
public void getViewId(String result) {
Log.d("Sid", "click-----------" + result);
}
}
我的HTML和JS代碼
</head>
<body>
<button onClick="saveId('122');">1</button>
<button onClick="saveId('222');">2</button>
<img onclick="saveId('imgClickEvent')" src="file:///android_res/drawable/dtech.png"/>
</body>
<script language="javascript">
function saveId(_id){
//Android keyword not found how to solve it ?
Android.getViewId(_id);
}
</script>