title: Resolving 2 symbols and adding elements in RecyclerView/CardView
body: <p>Im following <a href="https://knowledgecollisions.wordpress.com/2016/03/29/using-recyclerview-and-cardview-in-your-android-app/" rel="nofollow noreferrer">this tutorial</a>, and I followed the directions carefully, but I ran into a few problems. In my ItemView constructor, cardview and photo are "symbols that cannot be resolved":</p>
  
  <pre><code>ItemViewHolder(View itemView) {
              super(itemView);
              cv = (CardView)itemView.findViewById(R.id.cardview);
              title = (TextView)itemView.findViewById(R.id.title);
              cover = (ImageView)itemView.findViewById(R.id.photo);
          }
  </code></pre>
  
  <p>Here is the entire adapter class: </p>
  
  <pre><code>package com.example.aaronpries.myfinal;
  import android.content.Context;
  import android.support.v7.widget.CardView;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.List;
  
  public class ItemAdapter extends RecyclerView.Adapter&lt;ItemAdapter.ItemViewHolder&gt;{
  
      private Context context;
      private List&lt;Item&gt; books;
  
  
  
      ItemAdapter(List&lt;Item&gt; books){
          this.books = books;
      }
  
      @Override
      public int getItemCount() {
          return books.size();
      }
  
      @Override
      public ItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
          View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.activity_cal, viewGroup, false);
          ItemViewHolder bvh = new ItemViewHolder(v);
          return bvh;
      }
  
      @Override
      public void onBindViewHolder(ItemViewHolder bookViewHolder, int i) {
  
          bookViewHolder.title.setText(books.get(i).text);
          bookViewHolder.cover.setImageResource(books.get(i).imgID);
      }
  
      @Override
      public void onAttachedToRecyclerView(RecyclerView recyclerView) {
          super.onAttachedToRecyclerView(recyclerView);
      }
  
      public static class ItemViewHolder extends RecyclerView.ViewHolder {
          CardView cv;
          TextView title;
          ImageView cover;
  
  
  
          ItemViewHolder(View itemView) {
              super(itemView);
              cv = (CardView)itemView.findViewById(R.id.cardview);
              title = (TextView)itemView.findViewById(R.id.title);
              cover = (ImageView)itemView.findViewById(R.id.photo);
          }
      }
  
  }
  </code></pre>
  
  <p>This is my item class:</p>
  
  <pre><code>package com.example.aaronpries.myfinal;
  
  import java.io.Serializable;
  
  public class Item implements Serializable{
  
      public int id;
  
      public String text;
  
      public int imgID;
  }
  </code></pre>
  
  <p>Here is the recyclerview xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;android.support.v7.widget.RecyclerView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/recyclerview"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The Activity xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="match_parent"
      android:padding="16dp"
      &gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/cardview"
          &gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:padding="16dp"
              &gt;
  
              &lt;ImageView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/photo"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentTop="true"
                  android:layout_marginRight="16dp"
                  /&gt;
  
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/title"
                  android:layout_toRightOf="@+id/photo"
                  android:layout_alignParentTop="true"
                  android:textSize="30sp"
                  /&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And finally the Activity class: </p>
  
  <pre><code>public class CalActivity extends AppCompatActivity {
  
     String[] events = {"A","B","C","D","E","F","G"};
  
      Context context = this;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_cal);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          RecyclerView recycler = (RecyclerView)findViewById(R.id.recyclerview);
          LinearLayoutManager layoutManager = new LinearLayoutManager(context);
          recycler.setLayoutManager(layoutManager);
  
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                          .setAction("Action", null).show();
              }
          });
      }
  }
  </code></pre>
  
  <p>I'm trying to follow a few different tutorials on how to get this a RecyclerView working, but most of them don't show completed code at the end, and since I'm so new, I sometime have a hard time following. I also want to add an image and title text to the RecyclerView, so if you have suggestions on that I'd appreciate it. Do I just do Item.add("text",imgID) over and over again to populate the data?</p>