Custom Listview scroll hiding progressbar process and ImageView

前端 未结 5 746
予麋鹿
予麋鹿 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条回答
  •  旧时难觅i
    2021-01-19 01:57

    try to use a holder for your cell view

    put this class at the end of your adapter

    class ViewHolder {
            TextView txtName,txtStatus;
    
            ImageView imageView;
    
            public ViewHolder(View convertview) {
                txtName = (TextView) convertview.findViewById(R.id.txtName );
                imageView = (ImageView) convertview.findViewById(R.id.ColImgPath);
              //and so on...
    
    
            }
        }
    

    replace:

     if (convertView == null) {
            convertView = inflater.inflate(R.layout.list_upload, null);
        }
    

    with:

     if (convertview == null) {
                convertview = activity.getLayoutInflater().inflate(R.layout.list_upload, null);
                holder = new ViewHolder(convertview);
                convertview.setTag(holder);
            } else {
                holder = (ViewHolder) convertview.getTag();
            }
    

    after that do your job with holder...

    holder.imageView instead of imageView and so on for all views

提交回复
热议问题