html5开发,放在android环境里,打成apk,alert,confirm事件没反应,
发布网友
发布时间:2022-04-27 04:44
我来回答
共1个回答
热心网友
时间:2023-09-11 06:04
需要添加这段代码:
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
AlertDialog.Builder b2 = new AlertDialog.Builder(MyWebView.this)
.setTitle(R.string.title).setMessage(message)
.setPositiveButton("ok",
new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
result.confirm();
// MyWebView.this.finish();
}
});
b2.setCancelable(false);
b2.create();
b2.show();
return true;
}
}
转载自:http://www.iteye.com/problems/63149