Need help with EfficientAdapter?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

424 Stars 43 Forks Apache License 2.0 82 Commits 2 Opened issues


Create a new adapter for a RecyclerView or ViewPager is now much easier.

Services available


Need anything else?

Contributors list

# 169,619
72 commits
# 661,762
1 commit

Efficient Adapter for Android

Create a new adapter for a RecyclerView or ViewPager is now much easier.


Create a list of elements into a RecyclerView or ViewPager is not that easy for a beginner, and repetitive for others. The goal of this library is to simplify that for you.

How does it work?

Create a class ViewHolder (

for example). The method
will be call with the object, when an update of your view is require:
public class BookViewHolder extends EfficientViewHolder {
    public BookViewHolder(View itemView) {  super(itemView); }

protected void updateView(Context context, Book object) {
    TextView textView = findViewByIdEfficient(;
    // or just
    setText(, object.getTitle());


Give this ViewHolder class to the constructor of the adapter (SimpleAdapter) of your RecyclerView, with the resource id of your item view and the list of objects:

EfficientRecyclerAdapter adapter = new EfficientRecyclerAdapter(R.layout.item_book, BookViewHolder.class, listOfBooks);

And that's it!

It's also working with a ViewPager:

EfficientPagerAdapter adapter = new EfficientPagerAdapter(R.layout.item_book, BookViewHolder.class, listOfBooks);

Other features

Heterogenous list

For a list of different kind of objects, layout, viewholder…

EfficientRecyclerAdapter adapter = new EfficientRecyclerAdapter(generateListObjects()) {
    public int getItemViewType(int position) {
        if (get(position) instanceof Plane) {
            return VIEW_TYPE_PLANE;
        } else {
            return VIEW_TYPE_BOOK;

public Class extends EfficientViewHolder> getViewHolderClass(int viewType) {
    switch (viewType) {
        case VIEW_TYPE_BOOK:
            return BookViewHolder.class;
        case VIEW_TYPE_PLANE:
            return PlaneViewHolder.class;
            return null;

public int getLayoutResId(int viewType) {
    switch (viewType) {
        case VIEW_TYPE_BOOK:
            return R.layout.item_book;
        case VIEW_TYPE_PLANE:
            return R.layout.item_plane;
            return 0;


Efficient findViewById()


is CPU-consuming (this is why we use the ViewHolder pattern), this library use a
findViewByIdEfficient(int id)
into the ViewHolder class.

You can use it like a

findViewById(int id)
but the view return will be cached to be returned into the next call.

Your view id should be unique into your view hierarchy, but sometimes is not that easy (with an include for example). It's now easier to find a subview by specify the parent of this subview with

findViewByIdEfficient(int parentId, int id)
to say "the view with this id into the parent with this id".

Let the element be clickable

Your ViewHolder class can override the method

to tell is this element is clickable or not.

By default, the view is clickable if you have a listener on your adapter.


This library includes the proguard configuration file. If you want to add it manually:

-keepclassmembers public class * extends com.skocken.efficientadapter.lib.viewholder.EfficientViewHolder {
    public (...);


dependencies {
    compile 'com.skocken:efficientadapter:2.4.0'

Android Support library

If you are still using the deprecated Android Support Library (instead of AndroidX), please use the dependency 2.3.X instead.



Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.