java 如何在 Android ProgressDialog 中显示 SecondaryProgress?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10385007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 00:48:21  来源:igfitidea点击:

How to show the SecondaryProgress in a Android ProgressDialog?

javaandroidprogressdialogprogress

提问by Eghes

I need to show the secondary progress of a ProgressDialog on Android, but it shows only the first progressbar in the dialog.

我需要在 Android 上显示 ProgressDialog 的次要进度,但它只显示对话框中的第一个进度条。

This is the code I use:

这是我使用的代码:

progress = new ProgressDialog(this);
    progress.setIndeterminate(false);
    progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progress.setProgress(25);

    progress.setSecondaryProgress(10);

    progress.show();

回答by Chopin

That seems to have no effect if set before the dialog is shown.

如果在显示对话框之前设置,这似乎没有效果。

Try:

尝试:

final ProgressDialog progress = new ProgressDialog(this);

progress.setIndeterminate(false);
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

progress.setOnShowListener(new OnShowListener() {   

    public void onShow(DialogInterface dialog) {
        progress.setProgress(50);
        progress.setSecondaryProgress(75);
    }
});

progress.show();

EDIT

编辑

Progress Dialog with secondary progress

带有次要进度的进度对话框