HeaderFooterEmptyRecyclerView - android RecyclerView support Header Footer and Empty list

Overview

Android RecyclerView support Header Footer and Empty list


simple and useful


Install

Add to the dependency

	dependencies {
            implementation 'com.android.support:recyclerview-v7:27.1.1'            //required

            implementation 'com.miladheydari:headerfooteremptyrecyclerview:1.2.0'
	}

usage

first add HFERecyclerView and empty view to your layout

<com.miladheydari.hferecyclerview.HFERecyclerView
        android:id="@+id/recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        layout="@layout/empty"
        android:visibility="gone" />

your adapter must extend HFEAdapter
T is type of your data list and must use getItem(position) for geting item of list data

class Adapter(_data: List<String>?) : HFEAdapter<String>(_data) {
    override fun getItemView(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {

        return ViewHolder(inflater.inflate(R.layout.row, parent,false))

    }

    override fun onBindViewHolder(holder: android.support.v7.widget.RecyclerView.ViewHolder, position: Int) {
        when (holder) {
            is ViewHolder -> {
                holder.tv.text = getItem(position) //required

            }
            else -> {
            }

        }
    }


    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {

        var tv: TextView = view.findViewById(R.id.tv)

    }
}

initial HFERecyclerView and add header footer and attach emptyView

class MainActivity : AppCompatActivity() {
    private lateinit var hfeRecyclerView: HFERecyclerView
    private val listString: MutableList<String> = ArrayList()

    private lateinit var adapter: Adapter

    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        hfeRecyclerView = findViewById(R.id.recycler)

        val mLayoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)

        hfeRecyclerView.layoutManager = mLayoutManager
        hfeRecyclerView.itemAnimator = DefaultItemAnimator()

        hfeRecyclerView.emptyView = findViewById(R.id.empty_view)
        for (i in 1..20)
            listString.add("hii $i")

        adapter = Adapter(listString)
        hfeRecyclerView.adapter = adapter

        hfeRecyclerView.setFooter(LayoutInflater.from(this).inflate(R.layout.footer,hfeRecyclerView, false))
        hfeRecyclerView.setHeader(LayoutInflater.from(this).inflate(R.layout.header,hfeRecyclerView, false))

    }
}
hfeRecyclerView.setFooter(view)

set footer for HFERecyclerView and remove footer with pass null

hfeRecyclerView.setHeader(view)

set header for HFERecyclerView and remove header with pass null

hfeRecyclerView.emtyView = view

set emptyView to recycler view **optional

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

A RecyclerView solution, support addHeaderView、addFooterView
A RecyclerView solution, support addHeaderView、addFooterView

HeaderAndFooterRecyclerView Introduction HeaderAndFooterRecyclerView is a RecyclerView solution that supports addHeaderView, addFooterView to a Recycl

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

Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

Android library for RecyclerView to manage order of items and multiple view types.
Android library for RecyclerView to manage order of items and multiple view types.

recyclerview-binder Android Library for RecyclerView to manage order of items and multiple view types. Features Insert any items to wherever you want

Android Library to provide swipe, click and other functionality to RecyclerView

RecyclerViewEnhanced Android Library to provide swipe, click and other functionality to RecyclerView Usage Add this to your build.gradle file dependen

A lightweight synchronizer between Android's TabLayout and RecyclerView.

TabSync A lightweight synchronizer between Android's TabLayout and RecyclerView. The behavior of the synchronizer is that as you scroll through the Re

RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
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

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

Releases(1.0.0)
Owner
Milad Heydari
Milad Heydari
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
ScrollableList - learn how to efficiently display a list of text in a RecyclerView and understand its architecture.

ScrollableList Learn how to efficiently display a list of text in a RecyclerView and understand its architecture. activity_main RecyclerView widget he

null 0 Jan 3, 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
Pagination-RecyclerView - Simple and easy way to Paginating a RecyclerView

Pagination-RecyclerView Simple and easy way to Paginating a RecyclerView Android

Rakshit Nawani 0 Jan 3, 2022
A RecyclerView Adapter which allows you to have an Infinite scrolling list in your apps

Infinite Recycler View A RecyclerView Adapter which allows you to have an Infinite scrolling list in your apps. This library offers you a custom adapt

IB Sikiru 26 Dec 10, 2019
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