在onPageFinished()之后的某个时刻WebView会更改页面

时间:2014-01-03 00:48:35

标签: android android-webview android-websettings webchromeclient

我在调用WebView时将onPageFinished()的可见性更改为可见,但在WebView呈现新页面之前,上一页可见一段时间。

有没有办法捕获WebView的页面渲染完成事件?

1 个答案:

答案 0 :(得分:0)

您可以在setWebViewclient上检测webview的开始和结束

webView.setWebViewClient(new WebViewClient(){
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        // TODO Auto-generated method stub
        super.onPageStarted(view, url, favicon);
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        // TODO Auto-generated method stub
        super.onPageFinished(view, url);
    }

    @Override
    public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {
        // TODO Auto-generated method stub
        super.onReceivedError(view, errorCode, description, failingUrl);
    }

    @Override
    public void onReceivedLoginRequest(WebView view, String realm,
                    String account, String args) {
        // TODO Auto-generated method stub
        super.onReceivedLoginRequest(view, realm, account, args);
    }
});