2013-02-22 77 views
0

在iPhone中,我們有像webViewDidStartLoad和webViewDidFinishLoad這樣的函數來檢查加載的開始和特定URL的完成。Android Webview函數

我們在Android上有這樣的嗎?

+0

Yes.Thnks的答案。 – iRunner 2013-02-23 04:02:30

回答

1

你可以嘗試這樣的事:

webView.setWebViewClient(new WebViewClient() { 
    public void onPageStarted(WebView view, String url, Bitmap favicon) { 
    super.onPageStarted(view, url, favicon); 
    // Do something here 
    } 

    public void onPageFinished(WebView view, String url) { 
    super.onPageFinished(view, url); 
    // Do something here 
    } 

    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 
    super.onReceivedError(view, errorCode, description, failingUrl); 
    // Do something here 
    } 
}); 
1

是的,你可以使用WebViewClient:

private class CustomWebClient extends WebViewClient{ 

    public void onPageStarted(WebView view, String url, Bitmap favicon) 
    { 

    } 

    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) 
    { 

    } 

    public void onPageFinished(WebView view, String url) 
    { 

    } 
} 

用法:

webView.setWebViewClient(新CustomWebClient());

每個方法的名字是自我解釋,你也可以檢查此:http://developer.android.com/reference/android/webkit/WebViewClient.html