notifyItemRemoved,notifyItemRangeRemoved和notifyItemRangeChanged(int positionStart, int itemCount, Ob
来源:互联网 发布:key-value数据库 编辑:程序博客网 时间:2024/06/08 05:19
1.public final void notifyItemRemoved(int position)
/**
* Notify any registered observers that the item previously located at position
* has been removed from the data set. The items previously located at and after
* position
may now be found at oldPosition - 1
.
*
*通知所有观察者之前在position位置的数据已经被remove
*
This is a structural change event. Representations of other existing items in the
* data set are still considered up to date and will not be rebound, though their positions
* may be altered.
* 这是一个结构性改变事件,其它还存在的数据的呈现依然被看成是最新的,虽然他们的position可能被更改了,但并不会被重新绑定
public final void notifyItemRemoved(int position) { mObservable.notifyItemRangeRemoved(position, 1); }
2.public void notifyItemRangeRemoved(int positionStart, int itemCount)
public void notifyItemRangeRemoved(int positionStart, int itemCount) {
// since onItemRangeRemoved() is implemented by the app, it could do anything, including
// removing itself from {@link mObservers} - and that could cause problems if
// an iterator is used on the ArrayList {@link mObservers}.
// to avoid such problems, just march thru the list in the reverse order.
采用倒序
for (int i = mObservers.size() - 1; i >= 0; i–) {
mObservers.get(i).onItemRangeRemoved(positionStart, itemCount);
}
}
public final void notifyItemRangeChanged(int positionStart, int itemCount) {
mObservable.notifyItemRangeChanged(positionStart, itemCount);
}
3. public final void notifyItemRangeChanged(int positionStart, int itemCount, Object payload)
/**
* Notify any registered observers that the itemCount
items starting at
* position positionStart
have changed. An optional payload can be
* passed to each changed item.
*
*
This is an item change event, not a structural change event. It indicates that any
* reflection of the data in the given position range is out of date and should be updated.
* The items in the given range retain the same identity.
*
*
*
* Client can optionally pass a payload for partial change. These payloads will be merged
* and may be passed to adapter’s {@link #onBindViewHolder(ViewHolder, int, List)} if the
* item is already represented by a ViewHolder and it will be rebound to the same
* ViewHolder. A notifyItemRangeChanged() with null payload will clear all existing
* payloads on that item and prevent future payload until
* {@link #onBindViewHolder(ViewHolder, int, List)} is called. Adapter should not assume * that the payload will always be passed to onBindViewHolder(), e.g. when the view is not * attached, the payload will be simply dropped. * * 如果item被ViewHolder呈现,那么这些数据会重新绑定到原来的ViewHolder上,如果payload为null,notifyItemRangeChanged()会被调用并且拒绝之后的payload直到onBindViewHolder(ViewHolder, int, List)被调用,适配器并不保证payload总是被传递到onBindViewHolder()方法,比如当View没有attach的时候,payload会被取消。 * @param positionStart Position of the first item that has changed * @param itemCount Number of items that have changed * @param payload Optional parameter, use null to identify a "full" update * * @see #notifyItemChanged(int) */ public final void notifyItemRangeChanged(int positionStart, int itemCount, Object payload) { mObservable.notifyItemRangeChanged(positionStart, itemCount, payload); }
- notifyItemRemoved,notifyItemRangeRemoved和notifyItemRangeChanged(int positionStart, int itemCount, Ob
- unsigned int 和int
- int...和int[]
- int 和 unsigned int
- 指针和引用(int*、int&、int*&、int&*、int**)
- 指针和引用(int*、int&、int*&、int&*、int**)
- _指针和引用(int*、int&、int*&、int&*、int**)
- 指针和引用---int*、int&、int*&、int&*、int**
- 指针和引用(int*、int&、int*&、int&*、int**)
- int?和??
- int[]、int[,]和int[][]区别联系
- int.Parse()和int.Tryparse
- const int*和int const*
- const int* 和 int const*
- (int*) 和 (int&)的区别
- int(*p)[]和int(**p)[]
- int(*p)[]和int(**p)[]
- int _tmain和int main
- 属性动画
- 常见前端面试题及答案(下)
- 最短路径问题
- 模拟实现库函数atoi
- Java集合系列(6)--HashMap
- notifyItemRemoved,notifyItemRangeRemoved和notifyItemRangeChanged(int positionStart, int itemCount, Ob
- PAT 1011
- 公元前的智能世界
- [Qt][Floyd算法] 动态规划求解最短行驶路径 源码及演示程序
- 求两个数的最大公约数
- 【bzoj3122】【SDOI2013】 随机数生成器
- 近代的智能世界
- Java-WebSocket wss通信异常
- Mac 下 IntelliJ idea创建Spring MVC的Maven项目的 练习