Android error when calling "requestWindowFeature (Window.FEATURE_PROGRESS)"; in activity

I am trying to show download progress for WebView in Android activity. When I try to display a progress bar of a window with:

requestWindowFeature( Window.FEATURE_PROGRESS );

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

When an error occurs, I see a new tab "ActivityThread.performLaunchActivity" in Eclipse, which has the message "Source not found". and the button "Change source search path ...".

When I delete the violation line, I do not get this error.

What can cause this problem? Do I need to set permission in the AndroidManifest.xml file or is there something else that I am missing?

+5
source share
5 answers

Did you try to make your call requestWindowFeature()before the call setContentView()?

This is necessary according to this post .

Docs for Window.requestFeature ():

Enable advanced screen features. This must be called before setContentView (). It can be named many times as desired if it is before setting setContentView ().

+13
source

Using:

public class MainActivity extends Activity

instead:

public class MainActivity extends ActionBarActivity
+5
source

, requestWindowFeature( Window.FEATURE_PROGRESS );, setContentView() onCreate().

+2

targetSdkVersion 19, . requestWindowFeature . xml minSdkVersion 8, .

0
source

aliosmeen is right. You need to expand Activityinstead ActionBarActivity. Both classes, for some reason, implement the method requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);in different ways. I did it like this and it no longer crashes. Although you must call the method requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);before you call the method setContentView().

0
source

All Articles