Uncertain Progress in Android Action

I am trying to replicate the experience found while uninstalling an application in ICS. In particular, an indefinite progress indicator in the title bar. I tried using requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) and various methods on Activity , but to no avail. Instead, it displays a progress bar in the upper right corner of the screen / title. Am I missing something here? Or is it completely custom?

Here is the code I'm using:

 @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setProgressBarIndeterminate(true); setProgressBarIndeterminateVisibility(true); } 

Uninstall screenshots

+6
source share
3 answers

You are using the ActionBar uncertainty indicator, but you are looking for a ProgressBar View.

You can programmatically create a View or add it to a layout file, for example -

 <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminate="true" /> 

Typically, you can decide when it is displayed by calling .setVisibility(View.VISIBLE) to display and .setVisibility(View.GONE) when you are done.

If you have a minimum API of 11 and set the theme of the activity or application to @android:style/Theme.Holo , you will get exactly what the ProgressBar shown in your image.

If you want a similar effect on pre-API 11 devices, check out HoloEverywhere

+8
source

Disclaimer: @iagreen's answer still remains true - to get a layout similar to that in the uninstall process, the best option is to just use it in the layout, rather than relying on the window functions)

But you were on the right track with the Windows features, you just mixed two of them.

See this:

 setProgressBarIndeterminate(true); 

requires the progress bar [horizontal] to be undefined. And this:

 setProgressBarIndeterminateVisibility(true); 

shows a window of an indefinite progress bar - a thing is a completely different kind.

To clarify the situation, you will get a horizontal indefinite progress bar shown at the top of the window

 requestWindowFeature(Window.FEATURE_PROGRESS); setProgressBarIndeterminate(true); setProgressBarVisibility(true); 

and this will give you a progress bar in the action bar

 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(true); 
+4
source

With the horizontal bar in the image, the indicator of the indicator of the action is not defined, this is the Spinner style. You need to either create a custom view of the action bar, or place it as a main layout. You can hide the action bar and create a custom title for a specific action. Just use the vague spinner progress bar, this is what everyone expects to see in the action bar.

0
source

All Articles