2

Create a Complex RecyclerView Quickly with Groupie Library – Android Kotlin RecyclerView Tutorial

RecyclerView has become a standard element in any kind of Android app. It’s fast and efficient – at least for the user. For developers, however, it’s an entirely different story.

You have to manage so many things – create adapters, keep track of multiple view types and span sizes (when you’re using a GridLayoutManager). Let’s not forget that sometimes you want to use expandable groups with headers… Oh and you also have to manage your overall sanity when something breaks in the process!

Luckily there is a simple RecyclerView solution which works out-of-the-box but it can also be heavily customized if you want to play with it. Groupie is an open-source Android library aimed at helping you get rid of any RecyclerView related headaches.

Groupie organizes items into groups – Sections and ExpandableGroups. It supports the use of headers and updating the groups with changed items could not be simpler – just call update() and you don’t even need to call notifyItemMoved() or any of that stuff.

 

This post contains all the code that’s been written in this YouTube video.

 

You can also check out this GitHub repository: https://github.com/ResoCoder/Groupie-LibraryTutorial

build.gradle

 

item_fancy.xml

 

FancyItem.kt

 

item_expandable_header.xml

 

ExpandableHeaderItem.kt

 

activity_main.xml

 

MainActivity.kt

Matt Rešetár
 

Matt is an app developer with a knack for teaching others. Working as a senior software developer at HandCash, freelancer and most importantly developer educator, he doesn't have a lot of free time 😅 Yet he still manages to squeeze in tough workouts 💪 and guitar 🎸

  • Abayomi Yusuf says:

    This was a great tutorial.
    For me, it was better than the official documentation.

    How do I implement an onCLicklistener for the item in my activity or fragment.
    I am using a viewmodel for my fragment and I want to load a ‘details’ fragment when an item is clicked.

  • Faizan says:

    Hi Matej,
    I want to send multiple lists to myItem class. For single list, I am using the map function that iterates over the list and give me my model object and I set the data to views in Item class easily but I want to send another list. How can this be achieved??

  • >