Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Error When Calling "requestWindowFeature( Window.FEATURE_PROGRESS );" in Activity

Tags:

android

I'm attempting to display loading progress for a WebView in an Android Activity. When I attempt to display the window's progress bar with:

requestWindowFeature( Window.FEATURE_PROGRESS );

as per http://developer.android.com/guide/appendix/faq/commontasks.html#progressbar but at this point I get a debugging error.

When the error occurs I see a new tab "ActivityThread.performLaunchActivity" in Eclipse which has a message "Source not found." and a button "Edit Source Lookup Path...".

When I remove the offending line I don't get this error.

What could be causing this problem? Do I need to set a permission in the AndroidManifest.xml file or is there something else I'm missing?

like image 785
Zac Seth Avatar asked Mar 08 '11 15:03

Zac Seth


3 Answers

Have you tried making your requestWindowFeature() call before you call setContentView()?

This is necessary according to this post.

The docs for Window.requestFeature():

Enable extended screen features. This must be called before setContentView(). May be called as many times as desired as long as it is before setContentView().

like image 76
Matthew Willis Avatar answered Oct 29 '22 20:10

Matthew Willis


Use:

public class MainActivity extends Activity

instead of:

public class MainActivity extends ActionBarActivity
like image 38
aliosmeen Avatar answered Oct 29 '22 22:10

aliosmeen


Make sure you are calling requestWindowFeature( Window.FEATURE_PROGRESS ); before you call setContentView() in onCreate().

like image 42
Robby Pond Avatar answered Oct 29 '22 20:10

Robby Pond