title: How to display an ArrayList in a RecyclerView?
body: <p>I need to add an <code>Activity</code> where I can list the elements of an <code>ArrayList&lt;CustomClass&gt;</code> and I've seen there's a newer and better way to display lists - <code>RecyclerView</code>.</p>
  
  <p>My question is how to implement this into my app.
  I've found that I need to use an <code>Adapter</code>, but I don't quite understand how to implement the whole process correctly.</p>
  
  <p>If you're wondering, I'm referring to <a href="https://developer.android.com/training/material/lists-cards.html" rel="noreferrer">this</a> examples of the docs, which I have been reading.</p>
  
  <p>EDIT:</p>
  
  <p>After having updated my code, it says it cannot resolve the symbol <code>setOnEntryClickListener</code>:</p>
  
  <pre><code>public class voting extends Activity {
  
  
  RecyclerView myList;
  private ArrayList&lt;Player&gt; players; // Players
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_voting);
  
      Intent intent = this.getIntent();
      Bundle bundle = intent.getExtras();
      players = (ArrayList&lt;Player&gt;)bundle.getSerializable("PLAYERS");
  
      myList = (RecyclerView) findViewById(R.id.charactersList);
      myList.setLayoutManager(new LinearLayoutManager(this));
      CoursesAdapter adapter = new CoursesAdapter(players);
      myList.setAdapter(adapter);
  }
  
  // OR RecyclerView with a click listener
  
  CoursesAdapter clickAdapter = new CoursesAdapter(players);
  clickAdapter.setOnEntryClickListener(new CoursesAdapter.OnEntryClickListener() {
      @Override
      public void onEntryClick(View view, int position) {
          // stuff that will happen when a list item is clicked
      }
  });
  recyclerView.setAdapter(clickAdapter);
  }
  </code></pre>
  
  <p>So I've thought I had put that <code>interface</code> in the wrong place (very probably), infact I've put it in the Adapter class, at the end of it, right after the <code>onAttachedToRecyclerView()</code> Method:</p>
  
  <pre><code>    @Override
  public void onAttachedToRecyclerView(RecyclerView recyclerView) {
      super.onAttachedToRecyclerView(recyclerView);
  }
  
  
  private OnEntryClickListener mOnEntryClickListener;
  
  public interface OnEntryClickListener {
      void onEntryClick(View view, int position);
  }
  
  public void setOnEntryClickListener(OnEntryClickListener onEntryClickListener) {
      mOnEntryClickListener = onEntryClickListener;
  }
  
  
  
  }
  </code></pre>