Android ProgessBar while loading WebView -


in application, have webview loads url internet. now, due slow networks page takes long time load , user sees blank screen.

i want show progressbar while webview gets loaded , hide progessbar when webview gets loaded completely.

i know how use progressbar , asynctasks, here problem.

this code use load webview.

    mwebview = (webview) findviewbyid(r.id.webview);     mwebview.getsettings().setjavascriptenabled(true);     mwebview.setwebviewclient(new hellowebviewclient());     mwebview.loadurl(web_url); 

and custom webviewclient class

private class hellowebviewclient extends webviewclient {     @override     public boolean shouldoverrideurlloading(webview view, string url) {         view.loadurl(url);         return true;     } } 

now, if try show progressbar using asynctasks guess have give code load url in doinbackground() function of asynctask , show progress through onprogressupdate() function.

but, how load url inside doinbackground() doinbackground() runs on non-ui thread , wont able use mwebview.loadurl(web_url) inside it.

any suggestions? missing obvious? please guide me.

check source code. , solve problem...

public class appwebviewclients extends webviewclient {      private progressbar progressbar;      public appwebviewclients(progressbar progressbar) {         this.progressbar=progressbar;         progressbar.setvisibility(view.visible);     }     @override     public boolean shouldoverrideurlloading(webview view, string url) {         // todo auto-generated method stub         view.loadurl(url);         return true;     }      @override     public void onpagefinished(webview view, string url) {         // todo auto-generated method stub         super.onpagefinished(view, url);         progressbar.setvisibility(view.gone);     } } 

i think you.

thanks.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -