How to show the SecondaryProgress in a Android ProgressDialog?
Asked Answered
H

1

1

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();
Holomorphic answered 30/4, 2012 at 14:2 Comment(2)
if u set secondary progress to 10 and the initial progress to 25, definitely the secondary progress will be hidden since the progress is already at 25. try changing the values vice versa instead.Hennahane
I tried changing the values as you say, but the effect is the same...Holomorphic
C
13

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

Cormorant answered 30/4, 2012 at 14:30 Comment(5)
I tried this code. Same problem, the second progress bar is not shown;Holomorphic
Weird. I tested it and works for me. I'm going to update with a cap.Cormorant
@Holomorphic Good! What was the issue?Cormorant
I setted wrong progress number, and it didn't show... I expected showed two distinct progressbar...Holomorphic
@Holomorphic So, is the secondary bar hidden if its current number is less than the primary bar's number?Profligate

© 2022 - 2024 — McMap. All rights reserved.