title: Use custom View in a RecyclerView Adapter?
body: <p>I have a basic custom View which looks like this:</p>
  
  <pre><code>public class CustomView extends RelativeLayout {
  
      private User user;
  
      private ImageView profilePicture;
  
      public CustomView(Context context) {
          super(context);
          init();
      }
  
      public CustomView(Context context, AttributeSet attrs) {
          super(context, attrs);
          init();
      }
  
      private void init() {
          inflate(getContext(), R.layout.custom_layout, this);
  
          profilePicture = (ImageView) findViewById(R.id.profilePicture);
  
          // ACCESS USER MODEL HERE
          // e.g. user.getUsername()
      }
  
  }
  </code></pre>
  
  <p>As you can see, I'd like to access user data in the View (i.e.: <code>user.getUsername()</code>).</p>
  
  <p>I also need to be able to use the custom View in a <code>RecyclerView</code> Adapter.</p>
  
  <p>Here is what my Adapter currently looks like:</p>
  
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; {
  
      private Context context;
  
      private List&lt;User&gt; userData;
  
      public MyAdapter(Context context, List&lt;User&gt; userData) {
          this.context = context;
          this.userData = userData;
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public ViewHolder(View v) {
              super(v);
          }
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          LayoutInflater inflater = LayoutInflater.from(context);
  
          // HOW TO INFLATE THE CUSTOM VIEW?
  
          // ViewHolder viewHolder = new ViewHolder(customView);
  
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(final ViewHolder holder, int position) {
          // ANYTHING HERE?
      }
  
      @Override
      public int getItemCount() {
          return userData.size();
      }
  
  }
  </code></pre>
  
  <p>How can I inflate the custom View in the Adapter?<br>
  Also, should I put anything in <code>onBindViewHolder()</code>?</p>
  
  <p>Note: I <strong>must</strong> use a custom View, as I use this View under different Adapters (i.e.: not just this <code>RecyclerView</code> Adapter).</p>