Skip to content

1.0.16

Compare
Choose a tag to compare
@youlookwhat youlookwhat released this 21 Feb 13:38
· 106 commits to master since this release

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时,不能使用自带的下拉刷新。