Android examples for User Interface:WebView
wrap WebView with ProgressBar
//package com.java2s; import android.graphics.Bitmap; import android.net.http.SslError; import android.view.View; import android.webkit.SslErrorHandler; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import android.widget.Toast; public class Main { public static void wrapWebView(WebView webView, final ProgressBar progress) { WebSettings webSettings = webView.getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setSupportZoom(false); webView.setWebChromeClient(new WebChromeClient()); webView.setWebViewClient(new WebViewClient() { ///*from w w w . j a va2s . c om*/ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } // @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (progress != null) { progress.setVisibility(View.VISIBLE); } } // @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (progress != null) { progress.setVisibility(View.GONE); } } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { // TODO Auto-generated method stub super.onReceivedSslError(view, handler, error); } //webview @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); view.loadData("", "text/html", "utf-8"); Toast.makeText(view.getContext(), "received", android.widget.Toast.LENGTH_LONG).show(); } }); } }