RecyclerView之notifyDataSetChanged()

/**
 * Notify any registered observers that the data set has changed.
//通知所有的注册观察者数据已经发生改变
 *
 * <p>There are two different classes of data change events, item changes and structural
 * changes. Item changes are when a single item has its data updated but no positional
 * changes have occurred. Structural changes are when items are inserted, removed or moved
 * within the data set.</p>
//指出两种不同的数据变更事件,item变更 和 结构变更,其中item变更只涉及item数据的更新不会发生位置的·变化; 结构变更指当item被插入,移除或移动的事件
 *
 * <p>This event does not specify what about the data set has changed, forcing
 * any observers to assume that all existing items and structure may no longer be valid.
 * LayoutManagers will be forced to fully rebind and relayout all visible views.</p>
 *
//但是在notifyDataSetChanged中并不指定发生的是哪种数据变更事件,因此所有的观察者将认为当前所有存在的items和结构不在有效,LayoutManagers将被迫重新绑定和放松所有可见的视图
 * <p><code>RecyclerView</code> will attempt to synthesize visible structural change events
 * for adapters that report that they have {@link #hasStableIds() stable IDs} when
 * this method is used. This can help for the purposes of animation and visual
 * object persistence but individual item views will still need to be rebound
 * and relaid out.</p>
 *
 * <p>If you are writing an adapter it will always be more efficient to use the more
 * specific change events if you can. Rely on <code>notifyDataSetChanged()</code>
 * as a last resort.</p>
//当你写一个适配器时,你能更有效的针对事件改变写出对应的的事件处理,notifyDataSetChanged时最后的选择
 *
 * @see #notifyItemChanged(int)
 * @see #notifyItemInserted(int)
 * @see #notifyItemRemoved(int)
 * @see #notifyItemRangeChanged(int, int)
 * @see #notifyItemRangeInserted(int, int)
 * @see #notifyItemRangeRemoved(int, int)
 */
public final void notifyDataSetChanged() {
    mObservable.notifyChanged();
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值