views-widgets-samples icon indicating copy to clipboard operation
views-widgets-samples copied to clipboard

Example of adding subheaders

Open halfbaked opened this issue 9 years ago • 5 comments

Subheaders (aka section headers) in lists and grids very common and indeed part of the material design spec (http://www.google.fr/design/spec/components/subheaders.html).

On the implementation side, there appear to be two primary strategies for rendering the headers in the recycler view. One is to use an ItemDecorator and the other is to use two different ViewHolder types. This library https://github.com/timehop/sticky-headers-recyclerview appears to be leading the way on the decorator pattern, while this tidy example https://gist.github.com/gabrielemariotti/4c189fb1124df4556058 (which is apparently a port of some older google code) uses the view holder types and a wrapper adapter.

It would be great to see an example of the pattern the Inbox app uses, where the headers are dynamically generated based on the content of the items. It seems to be such a common pattern it could nearly be accommodated in the support library. Failing that the source code of the Inbox app would suffice ;)

halfbaked avatar Aug 19 '15 15:08 halfbaked

+1

almeric avatar Sep 17 '15 08:09 almeric

@halfbaked did you find any sample code ?

kumawatmanish avatar Feb 09 '16 18:02 kumawatmanish

It is a long time ago now... but maybe something like this will be useful to you https://github.com/willblaschko/header-footer-recycler-view

On 9 February 2016 at 19:32, kumawatmanish [email protected] wrote:

@halfbaked https://github.com/halfbaked did you find any sample code ?

— Reply to this email directly or view it on GitHub https://github.com/googlesamples/android-RecyclerView/issues/9#issuecomment-181994471 .

halfbaked avatar Feb 10 '16 06:02 halfbaked

+1 Pretty old issue, but hoping it gets added.

bpappin avatar Jan 11 '18 21:01 bpappin

+1 There are many good examples online. But, it would be great to get a good example from Google directly. :)

CyrilNoahRapid avatar Apr 12 '18 14:04 CyrilNoahRapid