onJsAlert没有响应水龙头后,Android的WebView [英] Android webview after onJsAlert not responding taps
问题描述
我重写像我WebChromeClient的onJsAlert行为:
I have override my WebChromeClient's onJsAlert behavior like:
WebChromeClient wvcc = new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
//...
return true;
}
}
我的应用程序成功地处理JS的警报和SUP pressed原来的警报。不过,警报事件后,我没有长点击我的按钮(在列表视图列表项)在我的WebView在网页上。
我目前使用jQuery Mobile的建立我的网页。
my application successfully handle the Js alerts and suppressed the original alert. However, after the alert event, I can no long click my buttons(in list-items of listview) on the web page in my webview. I am currently using jquery mobile to build my web.
还有什么我应该知道的?
Is there anything else I should aware of?
推荐答案
我只是面对完全一样的问题。我想生成一个定制的Android对话,而不是警报,这是最终的解决方案:
I just faced the exactly same problem. I wanted to generate a custom android dialog instead of the alert, to this is the final solution:
myWebView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, final String url, String message,
JsResult result) {
AlertDialog.Builder builder = new AlertDialog.Builder(
MainActivity.this);
builder.setMessage(message)
.setNeutralButton("OK", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
arg0.dismiss();
}
}).show();
result.cancel();
return true;
}
});
关键是 result.cancel();
和返回true;
,我在若干组合进行测试,而没有解雇默认JS警报并没有引起触摸的问题是这样的组合是唯一一个
The key is the result.cancel();
and return true;
, I tested in several combinations, and the only one that did not fired the default JS alert AND didn't caused the touch problem was this combination
这篇关于onJsAlert没有响应水龙头后,Android的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!