 |
|
|  |
Android WebPageLoader with progress - bar |
|
|
 |
8³â Àü |
http://upadhyayjiteshandroid.blogspot.kr/2013/01/android-webpageloader-with-progress-bar.html
http://upadhyayjiteshandroid.blogspot.kr/2013/01/custom-progress-view-on-android-webview.html
WebPageLoader is an interactive way to show progress bar while downloading the web page.
Create a new Android project in Eclipse and name it whatever you wish. I named mine ¡°WebPageLoader¡±.
WebPageLoader.java
package com.jitesh.webpageloader;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebPageLoader extends Activity {
final Activity activity = this;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if (progress == 100)
activity.setTitle(R.string.app_name);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webView.loadUrl("http://upadhyayjiteshandroid.blogspot.in/");
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/> |
|
̵̧ : 321 |
̵̧
¸ñ·Ï
|
|
|  |
|