1.进度条
View Code
1 requestWindowFeature(Window.FEATURE_PROGRESS);
2 mWebView.setWebChromeClient(new WebChromeClient(){
3 public void onProgressChanged(WebView view, int newProgress)
4 {
5 Log.d("webview","progress "+String.valueOf(newProgress));
6 activity.setTitle("Loading...");
7 TestAPPActivity.this.setProgress(newProgress * 100);
8 if (newProgress == 100)
9 activity.setTitle(R.string.app_name);
10 }
11 }
12
2 mWebView.setWebChromeClient(new WebChromeClient(){
3 public void onProgressChanged(WebView view, int newProgress)
4 {
5 Log.d("webview","progress "+String.valueOf(newProgress));
6 activity.setTitle("Loading...");
7 TestAPPActivity.this.setProgress(newProgress * 100);
8 if (newProgress == 100)
9 activity.setTitle(R.string.app_name);
10 }
11 }
12
2.防止跳转默认浏览器
1 mWebView.setWebViewClient(new WebViewClient() {
2 public void onReceivedError(WebView view, int errorCode,
3 String description, String failingUrl) { // Handle the error
4 }
5
6 public boolean shouldOverrideUrlLoading(WebView view, String url) {
7 view.loadUrl(url);
8 return true;
9 }
10 });
2 public void onReceivedError(WebView view, int errorCode,
3 String description, String failingUrl) { // Handle the error
4 }
5
6 public boolean shouldOverrideUrlLoading(WebView view, String url) {
7 view.loadUrl(url);
8 return true;
9 }
10 });