Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indeterminate progress in Android Activity

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

like image 404
DHamrick Avatar asked Jan 14 '13 16:01

DHamrick


People also ask

What is indeterminate progress bar android?

ProgressBar is used to display the progress of an activity while the user is waiting. You can display an indeterminate progress (spinning wheel) or result-based progress.

What are the correct types of progress available in android?

In android, the ProgressBar supports two types of modes to show the progress, those are Determinate and Indeterminate.

What are the different types of progress bars?

There are 2 types of progress bars: determinate and indeterminate. The former is used when the amount of information that needs to be loaded is detectable. The latter is used when the system is unsure how much needs to be loaded or how long it will take.

What is progressBar for?

Progress bars are used to show progress of a task. For example, when you are uploading or downloading something from the internet, it is better to show the progress of download/upload to the user. In android there is a class called ProgressDialog that allows you to create progress bar.


1 Answers

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

like image 62
iagreen Avatar answered Sep 19 '22 10:09

iagreen