Skip to content
Don't write a RecyclerView adapter again. Not even a ViewHolder!
Kotlin Java
Branch: master
Clone or download

Latest commit

Latest commit b19d66f Dec 3, 2017


Type Name Latest commit message Commit time
Failed to load latest commit information.
app Version 2.3.0 Nov 28, 2017
gradle/wrapper Version 2.3.0 Nov 28, 2017
lastadapter Version 2.3.0 Nov 28, 2017
.gitignore Minor code refactoring & gradle-wrapper added Jul 7, 2016 Update Dec 3, 2017
Jenkinsfile Updated Jenkinsfile May 16, 2017
LICENSE.txt Create LICENSE.txt Aug 9, 2016 Update Dec 3, 2017
build.gradle Version 2.3.0 Nov 28, 2017 Initial commit Jun 21, 2016
gradlew Version 2.1.0 Mar 27, 2017
gradlew.bat Initial commit Jun 21, 2016
settings.gradle Initial commit Jun 21, 2016

Download Android Arsenal License Gitter


Don't write a RecyclerView adapter again. Not even a ViewHolder!

  • Based on Android Data Binding
  • Written in Kotlin
  • No need to write the adapter
  • No need to write the viewholders
  • No need to modify your model classes
  • No need to notify the adapter when data set changes
  • Supports multiple item view types
  • Optional Callbacks/Listeners
  • Very fast — no reflection
  • Super easy API
  • Tiny size: ~30 KB
  • Minimum Android SDK: 9



// apply plugin: 'kotlin-kapt' // this line only for Kotlin projects

android {
    dataBinding.enabled true 

dependencies {
    compile 'com.github.nitrico.lastadapter:lastadapter:2.3.0'
    // kapt '' // this line only for Kotlin projects


Create your item layouts with <layout> as root:

<layout xmlns:android="">

        <variable name="item" type="com.github.nitrico.lastadapterproject.item.Header"/>

It is important for all the item types to have the same variable name, in this case "item". This name is passed to the adapter builder as BR.variableName, in this case BR.item:

// Java
new LastAdapter(listOfItems, BR.item)
           .map(Header.class, R.layout.item_header)
           .map(Point.class, R.layout.item_point)
// Kotlin
LastAdapter(listOfItems, BR.item)

The list of items can be an ObservableList if you want to get the adapter automatically updated when its content changes, or a simple List if you don't need to use this feature.


The LayoutHandler interface allows you to use different layouts based on more complex criteria. Its one single method receives the item and the position and returns the layout resource id.

// Java sample
new LastAdapter(listOfItems, BR.item)

private LayoutHandler handler = new LayoutHandler() {
    @Override public int getItemLayout(@NotNull Object item, int position) {
        if (item instanceof Header) {
            return (position == 0) ? R.layout.item_header_first : R.layout.item_header;
        } else {
            return R.layout.item_point;
// Kotlin sample
LastAdapter(listOfItems, BR.item).layout { item, position ->
    when (item) {
        is Header -> if (position == 0) R.layout.item_header_first else R.layout.item_header
        else -> R.layout.item_point 

For further information, please take a look at my article at Medium.

Custom fonts

You might also want to try FontBinder to easily use custom fonts in your XML layouts.


Thanks to Yigit Boyar and George Mount for this talk.


Miguel Ángel Moreno

I'm open to new job positions - Contact me!

AngelList Email Facebook Google+ Twitter


Copyright 2016 Miguel Ángel Moreno

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

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.