title: How RecyclerView concept works on android?
body: <p>I have created a basic app using RecyclerView and CardView from get tutorials from websites.</p>
  
  <p>App is working fine and I have some confusion.(I am showing my whole code here)</p>
  
  <p>confusion is that how code works step by step. So please clear my concept on it.</p>
  
  <p>Basic Structure of my App :</p>
  
  <ol>
  <li>I have created a <code>row_data_layout</code> xml file to bind on <code>recycler_view</code>.</li>
  <li>Created an Data class file (Here I have defined my variable that I used in App).</li>
  <li>Created an Adapter file (here I want to clear how it works step by step first which class gets called and why?).</li>
  <li>Bind Data to <code>RecyclerView</code> on <code>MainActivity</code> file.</li>
  </ol>
  
  <p><code>row_data_layout.xml</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/CardView"
      android:paddingBottom="16dp"
      android:layout_marginBottom="16dp"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/txt_name"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:text="Large Text"
              android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>Data Class File:</p>
  
  <pre><code>public class Data {
      public String Name;
  
      Data(String Name)
      {
          this.Name=Name;
      }
  }
  </code></pre>
  
  <p>Data_Adapter Class file:</p>
  
  <pre><code>public class Data_Adapter extends RecyclerView.Adapter&lt;Data_Adapter.View_holder&gt; {
      List&lt;Data&gt; list = Collections.emptyList();
      Context context;
  
      public Data_Adapter(List&lt;Data&gt; list, Context context) {
          this.list = list;
          this.context = context;
      }
  
      @Override
      public Data_Adapter.View_holder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_data_layout,parent,false);
          View_holder holder=new View_holder(v);
          return holder;
      }
  
      @Override
      public void onBindViewHolder(Data_Adapter.View_holder holder, int position) {
              holder.name.setText(list.get(position).Name);
      }
  
      @Override
      public int getItemCount() {
          return list.size();
      }
  
      @Override
      public void onAttachedToRecyclerView(RecyclerView recyclerView) {
          super.onAttachedToRecyclerView(recyclerView);
      }
  
      public class View_holder extends RecyclerView.ViewHolder{
          CardView cv;
          TextView name;
  
          public View_holder(View itemView) {
              super(itemView);
              cv = (CardView) itemView.findViewById(R.id.CardView);
              name = (TextView) itemView.findViewById(R.id.txt_name);
          }
      }
  }
  </code></pre>
  
  <p>MainActivity File:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          List&lt;Data&gt; data = fill_data();
          RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
          Data_Adapter adapter = new Data_Adapter(data,getApplicationContext());
          recyclerView.setAdapter(adapter);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
      }
  
      public List&lt;Data&gt; fill_data()
      {
          List&lt;Data&gt; data = new ArrayList&lt;&gt;();
          data.add(new Data("Bred Pit"));
          data.add(new Data("Leonardo"));
  
          return data;
      }
  }
  </code></pre>