title: How Lists (specifically, RecyclerView with CardViews) in Android work
body: <p>Forgive me for asking this question, but I am new to Android development and although I am trying to go through the basics on the developer.android.com website, most of the samples (even though they say they're built for Android Studio) are not already setup to use Gradle and thus do not build unless you migrate them over to Gradle, and when you do that it either doesn't do anything or you get tons of errors.</p>
  
  <p>I've been trying to learn how to create Lists.</p>
  
  <p>I've read a bunch of tutorials on this from different sources. I've read the Android documentation. I've even read through the source code of the Android samples even though I couldn't get a few of them to build.</p>
  
  <p>I've tried writing my own code but I just don't understand the logic (for lack of a better word) behind creating List controls/elements/views in Android and binding/inserting data to them.</p>
  
  <p>I am trying to create a <a href="https://developer.android.com/training/material/lists-cards.html" rel="nofollow noreferrer">CardView</a> list. I don't understand how to create a List (of any type) and insert <em>items</em> into it at runtime (in a foreach loop for example). I thought that CardView was a list of its own, but it turns out it's just another control/view, kind of like a list item, and you add many to a list. I've read that you should put CardViews in a RecyclerView (which I think is a list). But all of the samples I've tried don't even build due to errors. So this just adds to the confusion while trying to learn how things work.</p>
  
  <p>How do I create a RecyclerView list and add CardView items to it at runtime in a for/foreach loop, for example?</p>
  
  <p><img src="https://i.stack.imgur.com/gDLlt.png" alt="enter image description here"></p>