android - Progress Bar Error at runtime -


the program keeps crashing when try run on handset. cant figure out why crashing

main java

public class progressbar extends activity {  webview webview; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); this.getwindow().requestfeature(window.feature_progress); setcontentview(r.layout.main );  final activity myactivity = this;  // makes progress bar visible getwindow().setfeatureint( window.feature_progress, window.progress_visibility_on);  webview = (webview) findviewbyid(r.id.webview); webview.setwebchromeclient(new webchromeclient() {     public void onprogresschanged(webview view, int progress)        {      //make bar disappear after url loaded, , changes string loading...     myactivity.settitle("loading...");      myactivity.setprogress(progress * 100); //make bar disappear after url loaded       // return app name after finish loading         if(progress == 100)            myactivity.settitle(r.string.app_name);       }     });  webview = (webview) findviewbyid(r.id.webview); webview.setwebviewclient(new hellowebviewclient()); webview.getsettings().setjavascriptenabled(true); webview.loadurl("http://www.google.com/");  } private class hellowebviewclient extends webviewclient {      @override     public boolean shouldoverrideurlloading(webview view, string url)     {         view.loadurl(url);     return true;     }     }     public boolean onkeydown(int keycode, keyevent event) {     if ((keycode == keyevent.keycode_back) && webview.cangoback()) {     webview.goback();     return true;     }     return super.onkeydown(keycode, event);     }     } 

xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     > <webview  xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/webview"     android:layout_width="fill_parent"     android:layout_height="fill_parent" /> <textview       android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:text="@string/hello"     /> </linearlayout> 

you'll want find stacktrace crash, can logcat, either open logcat view in eclipse (or open ddms perspective), or run adb logcat shell see log.

in case though, i'm pretty sure you'll see error saying need set window feature before creating content, move setcontentview call after getwindow().requestfeature call.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -