问题
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