1

我开发了一个应用程序,它在进度条中显示下载进度。

while ((chunkBytes = httpInputStream.read(outputByte, 0, 1024)) != -1) {

                bytesRead = bytesRead + chunkBytes;
                // write contents to the file
                fileOutputStream.write(outputByte, 0, (int) chunkBytes);
                // publish the progress of downloading.. 
                publishProgress((int)((bytesRead)*100/fileSize));

            }

但是,我想要做的是 - 而不是 58/100 ..(次要进度?)想在该进度下方显示 3.5 mb/5.5 mb ....(下载的 MB/总 MB)..我有试图改变次要进度但无济于事..还有其他方法吗?

4

1 回答 1

0

如果要更改进度条中显示的内容,则必须setProgressNumberFormat()使用字符串参数调用,该参数表示您希望看到的内容,例如,“%1d/%2d”将显示默认的“20/100”消息,而“%1d MB of %2d MB”将显示您要询问的内容。“%1d”是您当前的进度值,“%2d”是您的最大值,您可能会更改为setMax(int max)

于 2012-05-02T09:22:43.123 回答