. Android library that integrate sticky section headers in your RecyclerView

Overview

recyclerview-stickyheaders

Recyclerview-stickyheaders is an Android library that makes it easy to integrate section headers in your RecyclerView. These sections headers stick to the top as you can see below :

Deprecated

I don't have enought time to maintain this lib anymore. Retrospectively, I'm not sure that ItemDecoration is the best way to implement sticky headers, especially when dynamic add, remove and reorder of items is needed. If you need sticky headers feature, have a look to SuperSLiM or FlexibleAdapter. If you are interested by taking ownership of this repository, please contact me.

Comments
  • Error IndexOutBoundsException when multiple delete item

    Error IndexOutBoundsException when multiple delete item

    Firstly, thank you for your handwork, but I got issue when try to multiple delete from the bottom of item it always got IndexOutBoundsException, but if i just remove it individually it was good, and if i multiple delete from top item sometimes good sometimes got error.

    java.lang.IndexOutOfBoundsException: invalid position 37. State item count is 36 at android.support.v7.widget.RecyclerView$Recycler.convertPreLayoutPositionToPostLayout(RecyclerView.java:3234) at android.support.v7.widget.RecyclerViewHelper.convertPreLayoutPositionToPostLayout(RecyclerViewHelper.java:6) at library.StickyHeadersItemDecoration.isHeader(StickyHeadersItemDecoration.java:110) at library.StickyHeadersItemDecoration.onDrawOver(StickyHeadersItemDecoration.java:58)

    *note i use https://github.com/writtmeyer/recyclerviewdemo for multiple delete item

    bug 
    opened by fjr619 19
  • IndexOutOfBoundsException when deleting the last item

    IndexOutOfBoundsException when deleting the last item

    Hi, with the latest version (0.4.3) I get a IndexOutOfBoundsException (Invalid index 0, size is 0) when I delete the last item from my Adapter.

    This is the code I use:

    public void deleteVocable(Vocable vocable) {
            for (int i = 0; i < data.size(); i++) {
                if (vocable.getId() == data.get(i).getId()) {
                    data.remove(i);
                    this.notifyItemRemoved(i);
                    break;
                }
            }
        }
    
    bug 
    opened by rubengees 15
  • Warnings when building project

    Warnings when building project

    Hi, I have an issue when using your library. When I try to build my project with the command 'gradle build', I get the following warnings:

    Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1: can't find referenced method 'android.support.v7.widget.RecyclerView access$100(com.eowise.recyclerview.stickyheaders.HeaderStore)' in program class com.eowise.recyclerview.stickyheaders.HeaderStore Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced method 'java.util.HashMap access$000(com.eowise.recyclerview.stickyheaders.HeaderStore)' in program class com.eowise.recyclerview.stickyheaders.HeaderStore Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: com.eowise.recyclerview.stickyheaders.HeaderStore$1$1: can't find referenced class com.eowise.recyclerview.stickyheaders.HeaderInfo Warning: there were 7 unresolved references to classes or interfaces.

    I am using the library this way:

    dependencies { compile 'com.eowise:recyclerview-stickyheaders:0.5.1@aar' }

    So my project build fails with this exception:

    FAILURE: Build failed with an exception.

    java.io.IOException: Please correct the above warnings first.

    Do you know what might be the problem? Thank you very much in advance

    opened by Sandrichka22 10
  • Calendar Day Headers

    Calendar Day Headers

    possible I've been trying to use your library in order to create the picture above. Is it possible? How should I do it? I've failed miserably in order to create it.

    opened by HirogaKatageri 8
  • Another Force Close

    Another Force Close

    Hi, I just discovered a new Force Close:

    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewParent android.view.View.getParent()' on a null object reference
                at android.support.v7.widget.RecyclerView.getChildViewHolder(RecyclerView.java:2485)
                at com.eowise.recyclerview.stickyheaders.StickyHeadersTouchListener$SingleTapDetector.findItemHolderUnder(StickyHeadersTouchListener.java:78)
                at com.eowise.recyclerview.stickyheaders.StickyHeadersTouchListener$SingleTapDetector.onSingleTapConfirmed(StickyHeadersTouchListener.java:53)
                at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:273)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5221)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
    

    In my case I add one element with one header and then 2 other elements with another header. When I delete all items starting from the bottom, the app closes when I delete the last. (that at top) It looks like it has to do with the on header click listener which I use.

    bug 
    opened by rubengees 8
  • java.lang.IndexOutOfBoundsException: invalid position 1. State item count is 1

    java.lang.IndexOutOfBoundsException: invalid position 1. State item count is 1

    None of my code is hit in this stack trace (see below). I am getting this error when reducing the size of my list from many to 1 with an adapter change. I've traced the source of the issue to the face that when StickyHeaderItemDecoration.drawHeaders line:53 is called, the adapter has a size of 1, parent.mState has a size of 1, but parent.getChildCount() == 2 . The second unwanted view contains data from the previous version of the list that shouldn't be there.

    No matter how I notify the RecyclerView of an adapter change (notifyDataSetChanged, notifyItemRangeRemoved) the RecyclerView is out of sync with the adapter when StickyHeaderItemDecoration.drawHeaders is called - the for loop their picks up a child that should not exist.

    I have a dozen classes involved in this situation, so before I take the hours required to make a simpler version of this failure, do you have any suggestions?

      java.lang.IndexOutOfBoundsException: invalid position 1. State item count is 1
                at android.support.v7.widget.RecyclerView$Recycler.convertPreLayoutPositionToPostLayout(RecyclerView.java:3316)
                at android.support.v7.widget.RecyclerViewHelper.convertPreLayoutPositionToPostLayout(RecyclerViewHelper.java:9)
                at com.eowise.recyclerview.stickyheaders.HeaderStore.isHeader(HeaderStore.java:72)
                at com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration.drawHeaders(StickyHeadersItemDecoration.java:62)
                at com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration.onDrawOver(StickyHeadersItemDecoration.java:44)
                at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:2266)
                at android.view.View.getDisplayList(View.java:12838)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2930)
                at android.view.View.draw(View.java:13947)
                at android.view.View.getDisplayList(View.java:12838)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1060)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at com.jakewharton.madge.MadgeFrameLayout.drawChild(MadgeFrameLayout.java:85)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1060)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.draw(View.java:13947)
                at android.widget.FrameLayout.draw(FrameLayout.java:467)
                at android.view.View.getDisplayList(View.java:12838)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.draw(View.java:13947)
                at android.support.v7.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:509)
                at android.view.View.getDisplayList(View.java:12838)
                at android.view.View.getDisplayList(View.java:12880)
                at android.view.View.draw(View.java:13657)
                at android.view.ViewGroup.drawChild(ViewGroup.java:3086)
                at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2923)
                at android.view.View.getDisplayList(View.java:12833)
                at android.view.View.getDisplayList(View.java:12880
    
    bug 
    opened by nathanielwolf 6
  • Headers does not get updated when notifyItemMoved is called

    Headers does not get updated when notifyItemMoved is called

    I am having a list with the following structure. Header1 Item1 Item2 Item3 Header2 Item4 Header3 item5

    When I try to move the last three items to bottom of the list using notifyItemMoved I get the following the result

    Header2 Item4 Item5 Item1 Header1 Item2 Header1 Item3

    Calling notifydatasetChanged fixes this and produces the correct list Header2 Item4 Header3 Item5 Header1 Item1 Item2 Item3 But that makes the animation of the notifyItemMoved look very weird

    For me it looks like the placement of the headers does not get updated only the content of the already placed headers does get updated.

    opened by Hanspagh 5
  • Header is drawn on top of scrollbar

    Header is drawn on top of scrollbar

    When scrolling RecycleView it is clearly visible that headers overlay scrollbar, looks like scrollbar is under the header.

    My header layout:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="?listPreferredItemHeightSmall"
        android:background="@color/background_color"
        android:paddingTop="8dp"
        android:paddingStart="8dp"
        android:paddingEnd="8dp">
    
        <TextView
            android:id="@android:id/text1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:textAppearance="@style/TextAppearance.AppCompat.Title" />
    
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:src="?android:listDivider"
            android:scaleType="fitXY"/>
    
    </FrameLayout>
    
    opened by vovan888 4
  • Sometimes header do not push header on top of them when reaching the top of the views.

    Sometimes header do not push header on top of them when reaching the top of the views.

    Hi, Sometimes, when a header reach the top of the view (when scrolling down in a list for example), the header do not replace the one above him, but instead is drawn under the current top header. When the "future" top header reach totally the top of the view, it is finally correctly draw above the old header at top.

    What could occurs is that the "old" top header is not always correctly animated ?

    If needed, I can provide a sample project.

    opened by vincentbrison 3
  • ClickListeners on headers not working?

    ClickListeners on headers not working?

    I'm trying to register a click listener on the header view or any of it's child views. However, for some reason they don't seem to be called. Is this a known issue? Have you tried that before?

    Thanks, Stefan

    enhancement 
    opened by touchbee 3
  • fix measure in 4.2.2

    fix measure in 4.2.2

    The measure code breaks in 4.2.2 - at least thats my experience, I got a 5.0 and a 4.2.2 device and onmeasure breaks on the second one.

    Turns out that View.MeasureSpec.makeMeasureSpec(WRAP_CONTENT ... is wrong

    bug 
    opened by hazam 3
  • how can I update the header ?

    how can I update the header ?

    for example , i have got a checkbox on my header , I want to update the checkBox when I click the header (include the stickyHeader)
    how can I make it works ? Obviously , there is no method like "notifyDataSetChange" in StickyHeaderApapter

    opened by tracymac7fy 1
  • A new way to display Sticky Headers

    A new way to display Sticky Headers

    I wanted to test this project, but as the author said, it is deprecated, so I've worked on my implementation of the sticky headers still using a custom ItemDecoration but with a lot of advantages... The project is https://github.com/davideas/FlexibleAdapter. Adding, removing, dragging items are also covered, header is automatically re-linked to the item below.

    For information, I've also written an answer at this question: http://stackoverflow.com/questions/33018788/how-can-i-set-a-listener-inside-a-recyclerview-header-decor

    EDIT of 29/03/2016 Sticky Headers are now clickable using same listeners of the ViewHolder, not using anymore ItemDecoration. A FrameLayout is instead used.

    Finally, I agree with the author when he says that ItemDecoration is not the good way for sticky headers, and a custom LayoutManager or a ViewGroup should handle the HeaderView object. So I am searching help for this. The project SuperSlim is based on the LayoutManager, but it is a huge library: ~3400 lines for sections and sticky headers only(!?). However I did not test it for compatibility with my project.

    opened by davideas 1
  • appcompat-v7: 23.0.1 can not find mRecycler

    appcompat-v7: 23.0.1 can not find mRecycler

    public class RecyclerViewHelper {

    public static int convertPreLayoutPositionToPostLayout(RecyclerView recyclerView, int position) {
        return recyclerView.mRecycler.convertPreLayoutPositionToPostLayout(position);
    }
    

    }

    opened by xiang-jian 0
  • Bug: when using

    Bug: when using "top" StickyHeaders, it hides the scrollbar

    Since the header must have a background, it will hide the scrollbar of the RecyclerView in case it takes the whole width. And, if I choose to avoid having a background, it shows what's behind itself

    opened by AndroidDeveloperLB 0
Releases(v0.5.2)
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Emil Sjölander 5.5k Jan 2, 2023
ListView with blur/parallax/sticky capabilities

BlurStickyHeaderListView What is BlurStickyHeaderListView? It is a custom ListView with a header that displays pictures from an URL. It then adds a ni

null 129 Oct 26, 2022
Kotlin way of building RecyclerView Adapter 🧩. You do not have to write RecyclerView Adapters again and again and suffer from handling of different view types. Kiel will help you.

Kiel Kiel is a RecyclerView.Adapter with a minimalistic and convenient Kotlin DSL which provides utility on top of Android's normal RecyclerView.Adapt

ibrahim yilmaz 370 Jan 2, 2023
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.

SwipeToAction An easy way to add a simple 'swipe-and-do-something' behavior to your RecyclerView items. Just like in Gmail or Inbox apps. Integration

Victor Calvello 223 Nov 16, 2022
An Android Animation library which easily add itemanimator to RecyclerView items.

RecyclerView Animators RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations. Please feel

Daichi Furiya 11.2k Jan 5, 2023
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

RecyclerView-FlexibleDivider Android library providing simple way to control divider items of RecyclerView Release Note [Release Note] (https://github

Yoshihito Ikeda 2.4k Dec 18, 2022
Android library defining adapter classes of RecyclerView to manage multiple view types

RecyclerView-MultipleViewTypeAdapter RecyclerView adapter classes for managing multiple view types Release Note [Release Note] (https://github.com/yqr

Yoshihito Ikeda 414 Nov 21, 2022
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

Advanced RecyclerView This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-and-drop sorting and expa

Haruki Hasegawa 5.2k Dec 23, 2022
ItemDecoration for RecyclerView using LinearLayoutManager for Android

RecyclerItemDecoration RecyclerItemDecoration allows you to draw divider between items in recyclerview with multiple ViewType without considering item

magiepooh 328 Dec 27, 2022
Pumped up RecyclerView

##Description This is an attempt to make RecyclerView easier to use. Features built in: ProgressBar while adapter hasn't been set EmptyView if adapter

Anton Malinskiy 2.6k Jan 5, 2023
A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

RecyclerViewSwipeDismiss A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView. Preview How to use Add these lines to yo

xcodebuild 431 Nov 23, 2022
An adapter which could be used to achieve a parallax effect on RecyclerView.

android-parallax-recycleview Integration Step 1. Add the JitPack repository to your build file repositories { maven { url "https://jitpack

Pedro Oliveira 1.6k Nov 17, 2022
A Fast Scroller for the RecyclerView world!

RecyclerViewFastScroller The RecyclerViewFastScroller is a widget that can be added to a layout and connected to a RecyclerView for fast scrolling. Th

Daniel Smith 1.1k Dec 19, 2022
Dividers is a simple Android library to create easy separators for your RecyclerViews

Dividers Dividers is an Android library to easily create separators for your RecyclerViews. It supports a wide range of dividers from simple ones, tha

Karumi 490 Dec 28, 2022
Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.

FlabbyListView This library is not maintained anymore and there will be no further releases Android library to display a ListView which cells are not

JPARDOGO 762 Nov 23, 2022
Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.

ListBuddies This library is not maintained anymore and there will be no further releases Android library of a pair of auto-scroll circular parallax Li

JPARDOGO 970 Dec 29, 2022
Android library to observe scroll events on scrollable views.

Android-ObservableScrollView Android library to observe scroll events on scrollable views. It's easy to interact with the Toolbar introduced in Androi

Soichiro Kashima 9.6k Dec 29, 2022
An Android custom ListView and ScrollView with pull to zoom-in.

PullZoomView An Android custom ListView and ScrollView with pull to zoom-in. Features Set ZoomView enable Add HeaderView Custom ZoomView Parallax or N

Frank-Zhu 2.3k Dec 26, 2022
Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span

AsymmetricGridView An Android custom ListView that implements multiple columns and variable sized elements. Please note that this is currently in a pr

Felipe Lima 1.8k Jan 7, 2023