java - Why does my Application crash at startup? -
i can't change progress bar in webview application circle.the application crashes @ startup..here's code
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); webview = (webview) findviewbyid(r.id.webview); websettings websettings = webview.getsettings(); websettings.setjavascriptenabled(true); getwindow().requestfeature(window.feature_indeterminate_progress); // request progress circle setprogressbarindeterminatevisibility(true); // show progress circle // webview.setwebviewclient(new webviewclient()); final activity activity = this; webview.setwebchromeclient(new webchromeclient(){ public void onprogresschanged(webview view, int progress) { activity.settitle("loading..."); activity.setprogress(progress * 100); if(progress == 100) setprogressbarindeterminatevisibility(false); // hide progress circle when page loaded activity.settitle("title"); } }); if (savedinstancestate == null) { webview.loadurl("http://www.proboards.com/"); } }
someone can help?
your app crashes because line:
activity.getwindow().requestfeature(window.feature_indeterminate_progress);
needs called before calling activity.setcontentview(...);
you calling setcontentview(...) before, thats why app crashes.
here why, android-developer page:
http://developer.android.com/reference/android/view/window.html#requestfeature%28int%29
Comments
Post a Comment