How to show the SecondaryProgress in a Android ProgressDialog?

白昼怎懂夜的黑 提交于 2019-12-11 09:23:41

问题


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

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

回答1:


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



来源:https://stackoverflow.com/questions/10385007/how-to-show-the-secondaryprogress-in-a-android-progressdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!