content: package cn.refactor.cutoloadingviewdemo;
  
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  
  import java.util.List;
  
  /**
   * Create by andy (https://github.com/andyxialm)
   * Create time: 16/10/11 14:33
   * Description : Sample adapter
   */
  public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> {
  
      private List<Integer> mDataList;
  
      public ListAdapter(List<Integer> dataList) {
          mDataList = dataList;
      }
  
      @Override
      public ListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
          return new ListAdapter.ViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(ListAdapter.ViewHolder holder, int position) {
          holder.bind(mDataList.get(position));
      }
  
      @Override
      public int getItemCount() {
          return mDataList.size();
      }
  
      class ViewHolder extends RecyclerView.ViewHolder {
  
          ImageView imageView;
  
          ViewHolder(View itemView) {
              super(itemView);
              imageView = (ImageView) itemView.findViewById(R.id.iv_image);
          }
  
          void bind(int resId) {
              imageView.setImageResource(resId);
          }
      }
  }