Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Showing indeterminate progress bar in TabHost activity

Tags:

java

android

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.

like image 329
MattC Avatar asked Jul 16 '09 16:07

MattC


2 Answers

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);

like image 62
MattC Avatar answered Nov 17 '22 22:11

MattC


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);
        }
    });
like image 34
droidgren Avatar answered Nov 18 '22 00:11

droidgren