How to Use Fast Adapter in Android

How to Use Fast Adapter in Android

Introduction

Fast Adapter is a Android library for rapidly building Adapter without writing boilderplate so you could focus on development instead doing redundant task over and over

Steps

  • Add library to Android Project
  • Create POJO Class
  • Extend POJO with AbstractItem and Implment Methods

Add library to Android Project

Open your build level gradle file and add these lines

implementation 'com.mikepenz:fastadapter:3.3.1'
implementation 'com.mikepenz:fastadapter-commons:3.3.1'
implementation 'com.mikepenz:fastadapter-extensions:3.3.1'

Create POJO Class

class Note {
	private val title: String
    private val data: String
}

Extend POJO with AbstractItem

class Note : AbstractItem<Note, Note.ViewHolder>  {
	private val title: String
    private val data: String
}

Following methods needs to be implemented

  • getType() – return a unique ID (of your parent layout)
  • getLayoutRes() – return your XML layout resource
  • bindView() – RecyclerView’s onBindViewHolder() method

Original:  Updated: