java - Android Webview page load message -
im trying add message on webview if page thats trying load fails. possible? if so, possible message replace default "the webpage failed load" screen?
activity file
public class mainactivity extends activity { webview web; progressbar progressbar; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); web = (webview) findviewbyid(r.id.webview01); progressbar = (progressbar) findviewbyid(r.id.progressbar); web.setwebviewclient(new mywebclient()); web.getsettings().setjavascriptenabled(true); web.loadurl("http://www.technotalkative.com"); } public class mywebclient extends webviewclient { @override public void onpagestarted(webview view, string url, bitmap favicon) { // todo auto-generated method stub super.onpagestarted(view, url, favicon); } @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); } } @override public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_back) && web.cangoback()) { web.goback(); return true; } return super.onkeydown(keycode, event); } }
Comments
Post a Comment