MattC
MattC

Reputation: 12327

Android: Showing indeterminate progress bar in TabHost activity

I know that the following code should show and hide a tiny circular progress bar with the following code in Android:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
setProgressBarIndeterminateVisibility(false);

The problem is that I am using a TabHost and I need to be able to do this from one of the "child" activities. Is there any way I can go about doing this?

I found this question on the intarwebs but as you can see, it went unanswered.

Upvotes: 35

Views: 19790

Answers (2)

MattC
MattC

Reputation: 12327

And I found the answer. In your parent activity, before you do anything, you need to do the requestWindowFeature call, and then in your child activity you call getParent().setProgressBarIndeterminateVisibility(true/false);

Upvotes: 28

droidgren
droidgren

Reputation: 7118

Just for completeness:

If the task is running in a different thread other than Main ui thread, you can do:

    this.runOnUiThread(new Runnable() {
        public void run() {
            getParent().setProgressBarIndeterminateVisibility(mToggleIndeterminate);
        }
    });

Upvotes: 9

Related Questions