6

I am trying to replicate the experience found when you are uninstalling an app in ICS. Specifically the indeterminate progress indicator under the title bar. I have tried using requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) and the various methods on Activity but to no avail. It instead shows a spinning progress bar in the top right hand corner of the screen/title bar. Am I missing something simple here? Or is this completely custom?

Here is the code I am using:

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

    setProgressBarIndeterminate(true);
    setProgressBarIndeterminateVisibility(true);
}

Uninstall Screenshot

DHamrick
  • 8,338
  • 9
  • 45
  • 62
  • 1
    Have you tried using the `indeterminate` attributes on your `ProgressBar`? See http://stackoverflow.com/questions/6449345/android-indeterminate-progress-bar and http://developer.android.com/reference/android/widget/ProgressBar.html – saschoar Jan 14 '13 at 16:47
  • Show the code you are using. – Squonk Jan 14 '13 at 16:50

3 Answers3

10

You are using the ActionBar indeterminate progress bar, but you are looking for a ProgressBar View.

You can create the View programmatically or add it to a layout file like --

<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 shown by calling .setVisibility(View.VISIBLE) to show and .setVisibility(View.GONE) when you are done.

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

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

iagreen
  • 31,470
  • 8
  • 76
  • 90
  • HoloEverywhere looks like it has moved to here: https://github.com/Prototik/HoloEverywhere – Brett Sep 06 '13 at 19:01
4

Disclaimer: @iagreen's answer is still the right one -- to get layout similar to the one in uninstall activity your best option is to just use it in a layout, not rely on window features)

But you were on a right track with windows features, you just mixed two of them up.

See, this:

setProgressBarIndeterminate(true);

requests the window's [horizontal] progress bar to be indeterminate. And this:

setProgressBarIndeterminateVisibility(true);

shows the window's indeterminate progress bar -- thing is, it's a completely diffrerent view.

To clarify things further, this gets you a horizontal indeterminate progress bar shown at the top of the window

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

and this gets you a spinner-style progress bar in the actionbar

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
0

That's a horizontal progress bar in the image, the Action Bar indeterminate progress bar is a Spinner style. You'd either need to make a custom view for the action bar, or put it as a view in your main layout. You can hide the action bar and make a custom header for a particular activity. Just use the Spinner style indeterminate progress bar, it's what everyone expects to see in the Action Bar.

Noah Seidman
  • 4,359
  • 5
  • 26
  • 28