RecyclerView如何使用正确notifyItemRemo
2017-07-14 本文已影响607人
不识水的鱼
关于RecyclerView
如何使用正确notifyItemRemoved
,有一些坑必须要填,直接调用
data.remove(posiiton);
notifyItemRemoved(position);
position的位置回错乱, onBindViewHolder
不会调用,所以必须加上notifyItemRangeChanged
才行
public void removeItem(int position){
data.remove(posiiton);
notifyItemRemoved(position);
notifyItemRangeChanged(position, data.size() - position);
}
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
windowParams.dimAmount = 0.0f;
windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(windowParams);
}