为什么当我在适配器中调用编辑项目时我的 recyclerview 项目克隆?
Why my recyclerview item clones when i call edit item in adapter?
public void editMessage(Message editedMessage,int position) {
this.messagesItemList.set(position, new AdapterItem(editedMessage));
notifyItemChanged(position);
notifyItemRangeChanged(position, messagesItemList.size());
}
@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Message message = dataSnapshot.getValue(Message.class);
messageAdapter.editMessage(message, messageAdapter.getItemCount() - 1);
//messageAdapter.change(messageAdapter.getMessagesCount() - 1);
}
当我尝试调用编辑消息时,我的 RecyclerView 克隆了项目。
问题在一行
h.setIsRecyclable(false);
public void editMessage(Message editedMessage,int position) {
this.messagesItemList.set(position, new AdapterItem(editedMessage));
notifyItemChanged(position);
notifyItemRangeChanged(position, messagesItemList.size());
}
@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Message message = dataSnapshot.getValue(Message.class);
messageAdapter.editMessage(message, messageAdapter.getItemCount() - 1);
//messageAdapter.change(messageAdapter.getMessagesCount() - 1);
}
当我尝试调用编辑消息时,我的 RecyclerView 克隆了项目。
问题在一行
h.setIsRecyclable(false);