Android 调用DiffreResult.dispatchUpdatesTo(this)后未调用onBindViewHolder

Android 调用DiffreResult.dispatchUpdatesTo(this)后未调用onBindViewHolder,android,android-recyclerview,notifydatasetchanged,android-diffutils,Android,Android Recyclerview,Notifydatasetchanged,Android Diffutils,我通过以下方式将数据设置为“回收器视图”: public void setData(List<Notification> newNotifications) { DiffUtil.DiffResult diffResult = getDiffBetweenNewAndOldList(newNotifications); diffResult.dispatchUpdatesTo(this); this.notificationList.c

我通过以下方式将数据设置为“回收器视图”:

public void setData(List<Notification> newNotifications) {
        DiffUtil.DiffResult diffResult = getDiffBetweenNewAndOldList(newNotifications);
        diffResult.dispatchUpdatesTo(this);
        this.notificationList.clear();
        this.notificationList.addAll(newNotifications);
    }
当我刷新数据并再次获取列表的第一页时,则不会调用onBindViewHolder。当我使用notifyDataSetChanged()时,没有这样的问题。如何解决此问题?

您可以尝试:

public void setData(List<Notification> newNotifications) {
        DiffUtil.DiffResult diffResult = getDiffBetweenNewAndOldList(newNotifications);
        this.notificationList.clear();
        this.notificationList.addAll(newNotifications);
        diffResult.dispatchUpdatesTo(this);
}
public void setData(列出新通知){
DiffUtil.diffesult diffesult=GetDiffBetweenEndoldList(新通知);
此.notificationList.clear();
this.notificationList.addAll(newNotifications);
diffResult.dispatchUpdatesTo(本);
}
您可以尝试:

public void setData(List<Notification> newNotifications) {
        DiffUtil.DiffResult diffResult = getDiffBetweenNewAndOldList(newNotifications);
        this.notificationList.clear();
        this.notificationList.addAll(newNotifications);
        diffResult.dispatchUpdatesTo(this);
}
public void setData(列出新通知){
DiffUtil.diffesult diffesult=GetDiffBetweenEndoldList(新通知);
此.notificationList.clear();
this.notificationList.addAll(newNotifications);
diffResult.dispatchUpdatesTo(本);
}

它给出了相同的结果