Duplicate image show in recycle view in android

爱⌒轻易说出口 提交于 2019-12-12 04:48:28

问题


In recycle view the image shown duplicate sometimes. what is the reason to show the duplicate image.Not the all time sometime its occure

public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tvSubject.setText(chatSessions.get(position).getName());
        holder.tvMessage.setText(chatSessions.get(position).getLastUnreadMsg());
        holder.tvTime.setText(chatSessions.get(position).getTime());

        final String pictureLink = ServerRequestHandler.getPictureLink(chatSessions.get(position).getCsToken());

        Log.d("ChatListAdapter", position + ", pictureLink= " + pictureLink);
        Log.d("ChatListAdapter", chatSessions.get(position).getName() + ", Time= " + chatSessions.get(position).getTime());

        holder.profileLoadingView.setVisibility(View.GONE);
        holder.profilePicture.setVisibility(View.VISIBLE);
        holder.profilePicture.setImageDrawable(null);

        if (TaskUtils.isNotEmpty(pictureLink)) {

            imageLoader.displayImage((MainPageActivity) context, pictureLink, holder.profilePicture, holder.profileLoadingView);
        } else {
//            imageLoader.displayImage(null, holder.profilePicture, holder.profileLoadingView);

//            holder.profilePicture.setImageDrawable(context.getResources().getDrawable(R.drawable.photo));


            holder.profilePicture.setImageDrawable(null);
        }

I have added the screenn shot enter image description here


回答1:


The adapter have callback onViewRecycled(ViewHolder holder) you can use it to stop loading the image, and/or clear the cache of the already loader image. You have to check how does your image loading library works, and how to do it



来源:https://stackoverflow.com/questions/43586550/duplicate-image-show-in-recycle-view-in-android

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