[] Super fast and easy way to create header for Android RecyclerView

Overview

DEPRECATED

I created this library back in the day when I thought RecyclerView was all new and difficult. Writing an adapter that could inflate multiple types of Views seemed like a difficult job to do. In reality, RecyclerViewHeader is just a complex solution to a simple problem. Instead of using this library, just learn how to create a multi-type RecyclerView.Adapter. It will bring you a lot of value in the long run, and it is not difficult at all. Check the Migration section for the simplest example of such Adapter.

No new development will be taking place.

Thanks for all the support!


RecyclerViewHeader

License Maven Central

If you still wanna use this library, check the old README.md.

Migration

Just use a RecyclerView.Adapter that can inflate multiple types of items.

Here's the simplest one you could use:

class ExampleAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    companion object {
        private const val VIEW_TYPE_HEADER = 4815
        private const val VIEW_TYPE_ITEM = 1623
    }

    private val itemDataSetSize: Int get() = TODO("provide the size of your `ITEM` dataset")

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        when (viewType) {
            VIEW_TYPE_HEADER -> TODO("create your HEADER ViewHolder")
            VIEW_TYPE_ITEM -> TODO("create your ITEM ViewHolder")
            else -> error("Unhandled viewType=$viewType")
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        when (val viewType = getItemViewType(position)) {
            VIEW_TYPE_HEADER -> TODO("bind your HEADER ViewHolder")
            VIEW_TYPE_ITEM -> TODO("bind your ITEM ViewHolder")
            else -> error("Unhandled viewType=$viewType")
        }
    }

    override fun getItemCount(): Int = itemDataSetSize + 1 // 1 for header

    override fun getItemViewType(position: Int) = when (position) {
        0 -> VIEW_TYPE_HEADER
        else -> VIEW_TYPE_ITEM
    }
}

Developed by

  • Bartosz Lipiński

License

Copyright 2015 Bartosz Lipiński

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
RecyclerView : SleepQualityTracker with RecyclerView app
RecyclerView : SleepQualityTracker with RecyclerView app

RecyclerView - SleepQualityTracker with RecyclerView app SleepQualityTracker with RecyclerView This app builds on the SleepQualityTracker developed pr

RecyclerView with DiffUtil is a way to improve the performance of your app
RecyclerView with DiffUtil is a way to improve the performance of your app

RecylerViewSamples RecyclerView with DiffUtil is a way to improve the performanc

A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.
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

A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.
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

Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.
Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.

Pagination View Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagi

Easy RecyclerView Adapter

GenericAdapter Easy RecyclerView Adapter Getting started build.gradle allprojects { repositories { // ... maven { url 'https://jit

Just another one easy-to-use adapter for RecyclerView :rocket:
Just another one easy-to-use adapter for RecyclerView :rocket:

Elementary RecyclerView Adapter Another one easy-to-use adapter for RecyclerView 🚀 Features: DSL-like methods for building adapters similar to Jetpac

Dividers is a simple Android library to create easy separators for your RecyclerViews
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

A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.
A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.

UltimateRecyclerView Master branch: Dev branch: Project website:https://github.com/cymcsg/UltimateRecyclerView Description UltimateRecyclerView is a R

Comments
  • Up recycler view library. Fixed scroll listener issue

    Up recycler view library. Fixed scroll listener issue

    I have a complex views in my project and i faced some issues, when change view height dynamically. I checked source code and fix my problems. I create a pull request, maybe it will be helpful for someone, who use latest recyclerview library

    opened by dehimb 4
  • fix head not show correctly issue

    fix head not show correctly issue

    if the root view contains and EditText, whe hide the keyboard, then sometimes the recyclerview show correctly, but onScrollChanged is not call, so the head show incorrect

    opened by wutongke 0
Releases(2.0.1)
  • 2.0.1(May 18, 2016)

    • Fix: Scroll jump bug
    • Fix: Header not displaying if there are no items in the adapter
    • Headers exceeding RecyclerView's height (for vertical) or width (for horizontal) are no longer supported (you cannot scroll them if there are no items in the adapter)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Apr 7, 2016)

    Version 2.0.0 is the last, planned major release. It focuses on fixing all of the previously reported issues.

    • Attaching RecyclerViewHeader simplified. There's only one approach left (previously named Header-already-aligned approach).
    • New: Horizontal RecyclerViews support added
    • Fix: Header in wrong position after reusing fragment with RecyclerView
    • Fix: Removing an item misplacing header.

    StaggeredGridLayoutManager support has been temporarily disabled. This is planned to be re-enabled in a future release.

    Important:

    1. RecyclerViewHeader 2 uses a different package (com.bartoszlipinski.recyclerviewheader2), to make it easier to migrate gradually
    2. Maven group and artifact has been changed.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Feb 4, 2016)

  • 1.2.0(Apr 13, 2015)

    • StaggeredGridLayoutManager support
    • Reversed LayoutManagers support
    • Fix: scrolling with touch starting on a focusable element of the header
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Apr 8, 2015)

  • 1.0.1(Apr 8, 2015)

  • 1.0.0(Apr 8, 2015)

Owner
Bartek Lipinski
android engineer @reddit | former android tech lead @thefabulous | recovering feature creep💉| amateur air-drummer 🥁
Bartek Lipinski
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Jack and phantom 504 Dec 25, 2022
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
TikTok-RecyclerView - This is a demo app built using 'Koin' a new dependency injection framework for Android along with RecyclerView and ExoPlayer2.

TikTok-RecyclerView Demo About This is a demo app built using 'Koin' a new dependency injection framework for Android along with RecyclerView and ExoP

Baljeet Singh 19 Dec 28, 2022
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features

ChipsLayoutManager This is ChipsLayoutManager - custom Recycler View's LayoutManager which moves item to the next line when no space left on the curre

Oleg Beloy 3.2k Dec 25, 2022
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
Square Cycler API allows you to easily configure an Android RecyclerView declaratively in a succinct way.

Square Cycler – a RecyclerView API The Square Cycler API allows you to easily configure an Android RecyclerView declaratively in a succinct way. Desig

Square 791 Dec 23, 2022