【发布时间】:2019-10-20 21:49:34
【问题描述】:
在 Recycleview 中更新图像
我正在开发聊天应用程序,当用户在 Recycleview 中单击 imageview 时,我正在将图像下载到本地存储,然后尝试使用 picasso 重新加载,然后 Recycleview 正在跳转到另一个位置。
注意:根据我的研发,我理解 Imageview 在重新加载时需要焦点。我不确定,请让我了解在特定位置在 Recycleview 中重新加载图像的最佳方法是什么,而不会像 whatsapp 在点击下载时在聊天屏幕中加载图像那样跳跃。
我正在使用以下方法来更新特定位置。
notifyItemChanged(position);
如果我尝试使用以下方法重新加载,那么没问题,但是从 URI
加载时可能会出现 OOM(内存不足) messageImageView.setImageURI(Uri.fromFile(fileImage));
messageImageView.setImageResource(R.drawable.icn_conv_clicktodownload);
问题案例:
Picasso.get().load(fileImage).resize(viewWidth, viewHeight).
centerCrop().into(messageImageView);
【问题讨论】:
-
尝试 notifyItemInserted() 或 notifyItemRangeInserted 而不是 notifyItemChanged
-
@SachinSoma,谢谢,我也试过了,但仍然面临同样的问题。
标签: android android-recyclerview android-viewholder