在Android的回收视图中显示重复的图像 [英] Duplicate image show in recycle view in android

查看:92
本文介绍了在Android的回收视图中显示重复的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在回收站视图中,有时显示的图像重复.显示重复图像的原因是什么.并非总是在某个时间出现

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

我添加了屏幕截图 在此处输入图片描述

推荐答案

适配器具有回调onViewRecycled(ViewHolder holder),您可以使用它来停止加载映像,和/或清除已经加载的映像的缓存.您必须检查图片加载库的工作方式,以及如何做

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

这篇关于在Android的回收视图中显示重复的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆