你可以通过重写WebViewClient的onReceivedError方法来设置WebView加载页面时的超时时间,方法如下:
private class MyWebViewClient extends WebViewClient {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
if (errorCode == ERROR_TIMEOUT) {
// your timeout handling here
webView.setWebViewClient(new MyWebViewClient());