Groupie: Sticky Header

Created on 2 Sep 2018  路  3Comments  路  Source: lisawray/groupie

Is there a possibility for a Sticky header ?

question

Most helpful comment

qiujayen/sticky-layoutmanager works perfectly for my needs.

interface StickyItem {
    boolean isSticky();
}
class FooAdapter extends GroupAdapter implements StickyHeaders {

    // ...

    @Override
    public boolean isStickyHeader(int position) {
        Item item = getItem(position);
        return item instanceof StickyItem && ((StickyItem) item).isSticky();
    }
}
class FooHeaderItem extends Item<FooHeaderItem.Holder> implements StickyItem {

    // ...

    @Override
    public boolean isSticky() {
        return true;
    }
}
RecyclerView.LayoutManager lm = new StickyHeadersLinearLayoutManager<FooAdapter>(ctx);
mRecyclerView.setLayoutManager(lm).

All 3 comments

Please take a look at this. https://github.com/edubarr/header-decor

qiujayen/sticky-layoutmanager works perfectly for my needs.

interface StickyItem {
    boolean isSticky();
}
class FooAdapter extends GroupAdapter implements StickyHeaders {

    // ...

    @Override
    public boolean isStickyHeader(int position) {
        Item item = getItem(position);
        return item instanceof StickyItem && ((StickyItem) item).isSticky();
    }
}
class FooHeaderItem extends Item<FooHeaderItem.Holder> implements StickyItem {

    // ...

    @Override
    public boolean isSticky() {
        return true;
    }
}
RecyclerView.LayoutManager lm = new StickyHeadersLinearLayoutManager<FooAdapter>(ctx);
mRecyclerView.setLayoutManager(lm).

That's fantastic @iPaulPro ! I get asked about this all the time and I've always just said it's not in the scope of this library. A custom layout manager is a great solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MirzaAhmedBaig picture MirzaAhmedBaig  路  6Comments

spectrumIG picture spectrumIG  路  5Comments

Nimrodda picture Nimrodda  路  3Comments

vahids28 picture vahids28  路  4Comments

lisawray picture lisawray  路  7Comments