dynamic progress bar in android web view -
hello how can add page loading progress in . when page load prgress bar should .i want put code in case statement . in advance . here code
package com.menu; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.toast; public class menuactivity extends activity { webview mwebview; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mwebview = (webview) findviewbyid(r.id.webview); mwebview.getsettings().setjavascriptenabled(true); mwebview.loadurl("http://www.google.com"); mwebview.setwebviewclient(new webviewclient()); } public boolean oncreateoptionsmenu(menu menu) { new menuinflater(getapplication()) .inflate(r.layout.menu, menu); return(super.onprepareoptionsmenu(menu)); } public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.menu1: webview mywebview = (webview) findviewbyid(r.id.webview); mywebview.loadurl("http://...........com"); mywebview.setwebviewclient(new webviewclient()); break; case r.id.menu2: webview mywebview2 = (webview) findviewbyid(r.id.webview); mywebview2.loadurl("http://.................com/notice.php"); break; case r.id.menu3: webview mywebview3 = (webview) findviewbyid(r.id.webview); mywebview3.loadurl("http://...........com/original/services.php"); mywebview3.setwebviewclient(new webviewclient()); break; case r.id.submenu: toast.maketext(this, "sub menu", toast.length_short).show(); break; default: toast.maketext(this, "sub menu", toast.length_short).show(); ; } return(super.onoptionsitemselected(item)); } }
hi, try this..in webview.
mwebview.setwebchromeclient(new webchromeclient() { // called on page loading progress @override public void onprogresschanged(webview view, int newprogress) { super.onprogresschanged(view, newprogress); loadingprogressbar.setprogress(newprogress); // hide progress bar if loading complete if (newprogress == 100) { loadingprogressbar.setvisibility(view.invisible); } else { loadingprogressbar.setvisibility(view.visible); } } });
refer link
https://sites.google.com/site/cganapathi/progressbar-in-webview-ac
Comments
Post a Comment