WebView WebViewClient WebChromeClient

來源:互聯網
上載者:User

標籤:android   http   ar   java   sp   strong   資料   on   art   

在android中,瀏覽器的功能分成幾個部分,每個部分分工明確,互相協作。其中:

1. WebView :專門負責網頁資料解析和渲染;

2. WebViewClient :協助WebView處理各種請求和通知;

3. WebChromeClient :協助WebView處理js的對話方塊,網站表徵圖,網站title,頁面載入進度等;

 

WebView :常用方法

1. setWebViewClient   設定自訂WebViewClient

2. setWebChromeClient  設定自訂WebChromeClient

3. setDownloadListener   設定下載監聽

 

WebViewClient :常用方法

1. onPageStarted     開始載入網頁

2. onPageFinished    網頁載入結束

3. shouldOverrideUrlLoading   控制新的連結在當前WebView中開啟

4. onReceivedHttpAuthRequest   網頁驗證請求

5. onReceivedError     報告錯誤資訊

6. onReceivedSslError    報告SSL錯誤資訊

 

WebChromeClient :常用方法

1. onJsAlert ;  處理JS的Alert

2. onProgressChanged ; 頁面載入進度更新

3. onReceivedTitle    接收網頁標題,

 

PS: WebSettings:設定WebView的各種屬性和狀態

        1. setJavaScriptEnabled 設定JS是否可用

     2. setSupportZoom      設定是否支援縮放

   3. setBuiltInZoomControls     縮放控制

   4. setCacheMode  設定Cache模式

WebView WebViewClient WebChromeClient

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.