如何在 android 中设置进度条 0

How to set progress bar 0 in android

当用户取消下载时运行,进度条必须先到。为此,我设置了进度条 (0),但进度条没有转到第一个,而是保持在相同的情况下:

progressBar.setProgress(0);

我该怎么办?

进度条有两种模式:

1.Indeterminate模式

<ProgressBar
              android:id="@+id/indeterminateBar"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
        />

2.Determinate模式

<ProgressBar
      android:id="@+id/determinateBar"
      style="@android:style/Widget.ProgressBar.Horizontal" //this line is import!
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:progress="25"/> //initial progress bar position(25%), also could be set via java codes.

注意:setProgress方法对于不确定模式无效

我知道它工作正常。事实上,在 运行 这个方法之后,我应该停止包含更新进度条的循环