android ProgressBar updateing during download

痞子三分冷 提交于 2019-12-20 04:59:18

问题


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

回答1:


Try to call notifyDataSetChanged :

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


来源:https://stackoverflow.com/questions/26624151/android-progressbar-updateing-during-download

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!