title: Recyclerview adapter with CursorAdapter
body: <p>I'm trying to implement an adapter for a <code>Recyclerview</code> with the use of <code>CusrorAdapter</code> as below as suggested in the one of the solutions <a href="https://stackoverflow.com/questions/26517855/using-the-recyclerview-with-a-database">here</a>. </p>
  
  <p>I am new to Android and I don't quite know how I should override <code>CursorAdapter</code>'s newView method and <code>bindView</code> method. Also I am guessing that mine adapter will have multiple variables in <code>ViewHolder</code> instead of one (View v1) as there are several <code>textViews</code> in my layout file, but I just don't know how they all fit in in the code.</p>
  
  <pre><code>public class MyRecyclerAdapter extends Adapter&lt;MyRecyclerAdapter.ViewHolder {
  
  // PATCH: Because RecyclerView.Adapter in its current form doesn't natively support
  // cursors, we "wrap" a CursorAdapter that will do all teh job for us
  CursorAdapter mCursorAdapter;
  Context mContext;
  
  public MyRecyclerAdapter(Context context, Cursor c) {
      mContext = context;
      mCursorAdapter = new CursorAdapter(mContext, c, 0) {
  
          @Override
          public View newView(Context context, Cursor cursor, ViewGroup parent) {
              // Inflate the view here
          }
  
          @Override
          public void bindView(View view, Context context, Cursor cursor) {
              // Binding operations
  
          }
      };
  }
  
  public static class ViewHolder extends RecyclerView.ViewHolder{
      View v1;
      public ViewHolder(View itemView) {
          super(itemView);
          v1 = itemView.findViewById(R.id.v1);
      }
  }
  
  @Override
  public int getItemCount() {
      return mCursorAdapter.getCount();
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      // Passing the binding operation to cursor loader
      mCursorAdapter.bindView(holder.itemView, mContext, mCursorAdapter.getCursor());
  
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      // Passing the inflater job to the cursor-adapter
      View v = mCursorAdapter.newView(mContext, mCursorAdapter.getCursor(), parent);
          return new ViewHolder(v);
      }
  }
  </code></pre>