【发布时间】:2011-12-31 12:29:28
【问题描述】:
当我下载文件时,我希望进度条与此同步。但不是,我的代码是:
Thread thread = new Thread() {
public void run() {
try {
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
//add the data in the buffer to the file in the file output stream (the file on the sd card
fileOutput.write(buffer, 0, bufferLength);
//add up the size so we know how much is downloaded
downloadedSize += bufferLength;
pbar.setProgress((downloadedSize/totalSize)*100);
pbar.refreshDrawableState();
Log.d("CURRENT:", "" + (downloadedSize/totalSize)*100);
}
} catch (Exception ex) {
}
}
};
thread.start();
我的 catlog 文件也没有更新。请帮忙....
【问题讨论】:
标签: android progress-bar download