WebSettings wSet = wv.getSettings();
wSet.setJavaScriptEnabled(true);
wSet.setJavaScriptCanOpenWindowsAutomatically(true);
wv.loadUrl("file:///android_asset/dianli/gzp.html");
this.question = list.get(index).getQuestion();
wv.setWebChromeClient(new WebChromeClient(){
@Override
public boolean onJsAlert(WebView view, String url, String message,
final JsResult result) {
//Toast.makeText(AllQuestionActivity.this, "确定",Toast.LENGTH_LONG).show();
new AlertDialog.Builder(AllQuestionActivity.this)
.setTitle("找对了!")
.setMessage(message)
.setPositiveButton("ok",
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialoginterface, int i){
//按钮事件
//Toast.makeText(AllQuestionActivity.this, "确定",Toast.LENGTH_LONG).show();
}
}).show();
result.confirm();//如果不加这句,线程就会卡死,alert只会劫持一次,以后再也不会劫持
return true;
}
});