android - How to add a loading image to webview? -



android - How to add a loading image to webview? -

i'm working webview in android app... everytime open url page blank , after while url content appears... how can add together loading image in webview during transition time?? tried phone call open twice, first time loading local content , next time real url wanted feed doesn't work, think wrong async calls.

thanks in advance ^^

regards

here's how i'm doing it.

in main layout have spots webview , imageview. webview starts off 'gone' , loadingimage 'visible'.

<linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <imageview android:id="@+id/imageloading1" android:layout_height="wrap_content" android:layout_width="match_parent" android:visibility="visible" android:src="@drawable/loadingimage" /> <webview android:id="@+id/webview1" android:layout_height="wrap_content" android:layout_width="match_parent" android:visibility="gone" /> </linearlayout>

then in java load url. 1 time url done loading, swap out loading image webview.

webview wv; wv = (webview) findviewbyid(r.id.webview1); wv.setwebviewclient(new webviewclient() { //this grab link clicks on page, prevent opening new browser @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); homecoming true; } @override public void onpagefinished(webview view, string url) { //hide loading image findviewbyid(r.id.imageloading1).setvisibility(view.gone); //show webview findviewbyid(r.id.webview1).setvisibility(view.visible); } }); wv.loadurl("http://www.yourdomain.com/blahblahblah.htm");

please note: onpagefinished method utilize here works fine simple application, however, might not work case. deets how hear page finish loading, see thread --> how hear webview finishing loading url in android?

android

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -