Custom Listview scroll hiding progressbar process and ImageView

前端 未结 5 671
予麋鹿
予麋鹿 2021-01-19 01:27

I have a custom Listview, where each item contains a progressbar. But when the list contains many items, and I use the scrollbar to navigate through listview, some ProgressB

5条回答
  •  感情败类
    2021-01-19 02:07

    In your ViewHolder class :

    static class ViewHolder {
         //...
         boolean isUploading = false;
         //...
    }
    

    In your getView():

    public View getView(final int position, View convertView, ViewGroup parent) {
         //...
         if(holder.isUploading) {
               holder.uploadProgressBar.setVisibility(View.VISIBLE);
         } else {
               holder.uploadProgressBar.setVisibility(View.GONE);
         }
         //...
    }
    

    In your startUpload():

    public void startUpload(final int position) { 
         //...
         holder.uploadProgressBar.setVisibility(View.VISIBLE);
         holder.isUploading = true;
         //...
    }
    

    Hope it will work.

提交回复
热议问题