Skip to content

A library allows to add header and footer views for RecyclerView.

License

Notifications You must be signed in to change notification settings

kk-java/HeaderFooterRecyclerView

Repository files navigation

HeaderFooterRecyclerView

Android Arsenal

Screenshots

Getting started

This library is published on jCenter. Just add these lines to build.gradle.

dependencies {
    compile 'com.liucanwen.app:headerfooterrecyclerview:1.0.0'
}

Usage

private void refreshRecyclerView(int column) {

    MyAdapter myAdapter = new MyAdapter(MainActivity.this);
    HeaderAndFooterRecyclerViewAdapter adapter = new HeaderAndFooterRecyclerViewAdapter(myAdapter);
    recyclerView.setAdapter(adapter);

    ExStaggeredGridLayoutManager staggeredGridLayoutManager = new ExStaggeredGridLayoutManager(column, StaggeredGridLayoutManager.VERTICAL);
    staggeredGridLayoutManager.setSpanSizeLookup(new HeaderSpanSizeLookup((HeaderAndFooterRecyclerViewAdapter) recyclerView.getAdapter(), staggeredGridLayoutManager.getSpanCount()));
    recyclerView.setLayoutManager(staggeredGridLayoutManager);

    View headerView = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_header, null);
    View footerView = LayoutInflater.from(MainActivity.this).inflate(R.layout.layout_footer, null);

    RecyclerViewUtils.setHeaderView(recyclerView, headerView);
    RecyclerViewUtils.setFooterView(recyclerView, footerView);
}

License

Copyright 2016 liucanwen.

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

About

A library allows to add header and footer views for RecyclerView.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages