下载过程中的android进度updateing [英] android ProgressBar updateing during download
本文介绍了下载过程中的android进度updateing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的文件下载的应用程序有ListView中每一行包含属性文件和一个进度条下载它的地位和我一起查看持有人的模式,但进度条工作不更新
@覆盖
保护无效onProgressUpdate(长...值){
进度BAR1;
TextView的状态1;
DownloadStructure.setProgress(值[0] .intValue());
BAR1 = DownloadStructure.getProgressBarRefrence();
如果(BAR1!= NULL){
bar1.setVisibility(View.VISIBLE);
bar1.setMax(值[2] .intValue());
bar1.setProgress(DownloadStructure.getProgress());
bar1.Invalidate();
}
STATUS1 = DownloadStructure.getProgressTextviewRefrence();
如果(状态1!= NULL){
status1.setVisibility(View.VISIBLE);
status1.setText(DownloadStructure.getDownloadStatus());
status1.postInvalidate();
}
}
解决方案
尝试调用 notifyDataSetChanged
:
保护无效onPostExecute(布尔结果){
...
myListView.notifyDataSetChanged(); //或者如果你的异步内部适配器只需notifyDataSetChanged
}
in my file download app there is ListView that each row contain properties file and one ProgressBar for downloading status of it and i work with View Holder pattern but progress bar not update
@Override
protected void onProgressUpdate(Long... values) {
ProgressBar bar1;
TextView status1;
DownloadStructure.setProgress(values[0].intValue());
bar1 = DownloadStructure.getProgressBarRefrence();
if (bar1 != null) {
bar1.setVisibility(View.VISIBLE);
bar1.setMax(values[2].intValue());
bar1.setProgress(DownloadStructure.getProgress());
bar1.Invalidate();
}
status1 = DownloadStructure.getProgressTextviewRefrence();
if (status1 != null) {
status1.setVisibility(View.VISIBLE);
status1.setText(DownloadStructure.getDownloadStatus());
status1.postInvalidate();
}
}
解决方案
Try to call notifyDataSetChanged
:
protected void onPostExecute(Boolean result) {
...
myListView.notifyDataSetChanged(); //or simply notifyDataSetChanged if your Async inside adapter
}
这篇关于下载过程中的android进度updateing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文