Is there an addHeaderView equivalent for RecyclerView?

后端 未结 19 1957
独厮守ぢ
独厮守ぢ 2020-11-21 23:35

I\'m looking for an equivalent to addHeaderView for a recycler view. Basically I want to have an image with 2 buttons be added as a header to the listview. Is there a differ

19条回答
  •  情书的邮戳
    2020-11-22 00:13

    Native API doesn't have such "addHeader" feature, but has the concept of "addItem".

    I was able to include this specific feature of headers and extends for footers as well in my FlexibleAdapter project. I called it Scrollable Headers and Footers.

    Here how they work:

    Scrollable Headers and Footers are special items that scroll along with all others, but they don't belongs to main items (business items) and they are always handled by the adapter beside the main items. Those items are persistently located at the first and last positions.

    There's a lot to say about them, better to read the detailed wiki page.

    Moreover the FlexibleAdapter allows you to create headers/sections, also you can have them sticky and tens of others features like expandable items, endless scroll, UI extensions etc... all in one library!

提交回复
热议问题