How to show the SecondaryProgress in a Android Pro

2019-09-03 09:48发布

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条回答
我欲成王,谁敢阻挡
2楼-- · 2019-09-03 09:59

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

查看更多
登录 后发表回答