2017-04-24 80 views
0

在回收视图中,有时会显示重复的图像。什么是显示重复image.Not的原因,所有的时间有时它occure在Android的回收视图中显示重复的图像

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

我已经加入了screenn拍摄 enter image description here

+0

在这里发布你的屏幕截图 –

+0

pictureLink链接到不同的图像? – Christopher

+0

它由于图像加载器库,它缓存图像快速加载 –

回答

0

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

+0

我没有关于如何清除缓存的想法。你可以举例 –

+0

没有,因为我不知道'imageLoader'是什么。缓存可能不是罪魁祸首 - 你必须取消在这个回调 – X3Btel

+0

图像的装入其创建另一个问题...任何其他解决方案? –