Recyclerview中Item的view的复用,导致显示错乱
问题在于:
如果在 item中含有一个recyclerview,每次加载item时,并不会总是每次holer.mBinding.recyclerview.adapter == null,而是会复用上一个item的adapter,即:
holder.mBinding.recyclerview.adapter != null。
解决方法:
list = item.images.split(",") as MutableList<String>
if(holder.mBinding.recyclerViewImages.adapter == null) {
val imagesAdapter = FeedbackImagesAdapter(mContext)
imagesAdapter.setList(list)
holder.mBinding.recyclerViewImages.adapter = imagesAdapter
} else {
(holder.mBinding.recyclerViewImages.adapter as FeedbackImagesAdapter).setList(list)
}
这样就可以解决显示错乱问题。