Is there an addHeaderView equivalent for RecyclerView?

后端 未结 19 1607
独厮守ぢ
独厮守ぢ 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:28

    Based on this post, I created a subclass of RecyclerView.Adapter that supports an arbitrary number of headers and footers.

    https://gist.github.com/mheras/0908873267def75dc746

    Although it seems to be a solution, I also think this thing should be managed by the LayoutManager. Unfortunately, I need it now and I don't have time to implement a StaggeredGridLayoutManager from scratch (nor even extend from it).

    I'm still testing it, but you can try it out if you want. Please let me know if you find any issues with it.

提交回复
热议问题