Skip to content
A quick adapter library for RecyclerView, GridView, ListView, ViewPager, Spinner
Branch: master
Clone or download
UsherBaby release 2.1.1
Latest commit 4f17ce5 Nov 7, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
art add png Apr 15, 2016
pacific-adapter release 2.1.1 Nov 7, 2017 add demo Apr 17, 2017 add proguard Jul 16, 2017


A quick adapter library for RecyclerView, GridView, ListView, ViewPager, Spinner. It abstracts the boilerplate of item view types, item layouts, viewholders, span sizes , and more, in order to simplify building complex screens with multiple view types. 1.x is deprecated and please upgrade to 2.x

Download Android Arsenal


  • Support DataBinding.
  • Multiple view types without any ViewHolder
  • Simple, flexible


compile 'com.github.thepacific:adapter:{lastestVersion}'


-keep class android.databinding.DataBindingUtil {
   public static *;


Extend SimpleItem or SimpleRecylcerItem. Optionally, you may implement Item or RecylcerItem

public class YourItem extends SimpleItem {
    String name;
    String description;
    String imageUrl;

    public int getLayout() {
        return R.layout.item_cartoon;

    public void bind(ViewHolder holder) {
        //bind data
        DefaultBinding binding = holder.binding();
        binding.setText(, name);
        binding.setText(, description);

        //attach listeners or load image


    //You may override any other method


public class YourItem extends SimpleItem {
    public void bind(ViewHolder holder) {
        //Without DataBinding, just use DefaultBinding
        DefaultBinding binding = holder.binding();

        //With DataBinding, use layout generated Binding instead of DefaultBinding
        LayoutGeneratedBinding binding = holder.binding();


Set OnClickListener, OnLongClickListener, OnTouchListener, OnCheckedChangeListener and ImageLoader:

RecyclerAdapter adapter = new RecyclerAdapter(); //RecyclerView
AbsAdapter adapter = new AbsAdapter(int viewTypeCount);//GridView, ListView, Spinner
PagerAdapter2 adapter2 =new PagerAdapter2();//ViewPager

//set listeners or ImageLoader
adapter.setOnClickListener(OnClickListener listener);
adapter.setOnTouchListener(OnTouchListener listener);
adapter.setOnLongClickListener(OnLongClickListener listener);
adapter.setOnCheckedChangeListener(OnCheckedChangeListener listener);
adapter.setImageLoader(ImageLoader imageLoader);

adapter.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        //get ViewHolder
        ViewHolder holder = AdapterUtil.getHolder(v);

        //find view in ItemView
        TextView textName = AdapterUtil.findView(holder.itemView,;

        //get Item
        Item item = holder.getItem();

        //get adapter data size
        int size = holder.getSize();


        //for ListView,GridView, ViewPager, Spinner and RecyclerView
        int position = holder.getCurrentPosition();
        //only for RecyclerView
        int position = holder.getAdapterPosition();

adapter.setImageLoader((imageView, holder) -> {
    YourItem item = holder.getItem();


adapter.setOnDataSetChanged(OnDataSetChanged onDataSetChanged);

//data set changed callback , it's useful to show or hide empty view
public interface OnDataSetChanged {
    //called when data size is 0
    void onEmptyData();

    //called when data size larger than 0
    void onHasData();


The MIT License

You can’t perform that action at this time.