简体   繁体   English

Android:在TabHost活动中显示不确定的进度条

[英]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: 我知道以下代码应该在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. 问题是我正在使用TabHost,我需要能够从一个“子”活动中做到这一点。 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. 我在intarwebs上发现了这个问题 ,但正如你所看到的,它没有得到答复。

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); 在您的父活动中,在执行任何操作之前,您需要执行requestWindowFeature调用,然后在您的子活动中调用getParent().setProgressBarIndeterminateVisibility(true/false);

Just for completeness: 只是为了完整性:

If the task is running in a different thread other than Main ui thread, you can do: 如果任务在Main ui线程以外的其他线程中运行,则可以执行以下操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM