1.0.16
AndroidX:
- 增加悬浮item设置
1、使用StickyLinearLayoutManager
,传入adapter
StickyLinearLayoutManager layoutManager = new StickyLinearLayoutManager(getContext(), mAdapter);
2、在adapter里,将悬浮的item的ItemViewType设置为StickyHeaderHandler.TYPE_STICKY_VIEW
@Override
public int getItemViewType(int position) {
if (0 <= position && position < getData().size()) {
DataItemBean itemData = getItemData(position);
if ("title".equals(itemData.getType())) {
return StickyHeaderHandler.TYPE_STICKY_VIEW;
} else {
return 2;
}
}
return 2;
}
也可以使用
StickyGridLayoutManager
,只需将最后一个参数传入 adapter 即可
注意:使用置顶item时,不能使用自带的下拉刷新。