下载期间android ProgressBar更新

标签 android listview progress-bar

在我的文件下载应用程序中有一个 ListView,每一行都包含属性文件和一个用于下载它的状态的 ProgressBar,我使用 View Holder 模式,但进度条不更新

@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();
        }
    }

最佳答案

尝试调用 notifyDataSetChanged :

        protected void onPostExecute(Boolean result) {
            ...
            myListView.notifyDataSetChanged(); //or simply notifyDataSetChanged if your Async inside adapter
        }

关于下载期间android ProgressBar更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26624151/

相关文章:

android - ListView FullScreen-Item 水平滚动

java - 自定义 ListAdapter 的 Hashmap 中出现空指针异常?

c# - 如何在winforms上绘制自己的进度条?

android - onLongClick 只应在条件为真时发生

android - JNI 错误 : Attempt to pass an instance of TangoPointCloudData to onXyzIjAvailable

android - 奖励视频广告恢复方法

android - 在 Android 的两个选项卡上使用相同的 View

c# - ProgressBar 重置为 60%

android - 如何使线条变为曲线形状以填充图像

找不到 Android 方法 NetworkInterface.isUp()