title: Calling activity from ViewHolder in RecyclerView?
body: <p>I've got  a RecyclerView which is loading the content of my String arrays which works fine, however I want to open a new activity depending on which view they have pressed.</p>
  
  <p>What I have done is created an array called classes like so:</p>
  
  <pre><code>&lt;array name="classes"&gt;
      &lt;item&gt;ClassOne&lt;/item&gt;
      &lt;item&gt;ClassTwo&lt;/item&gt;
      &lt;item&gt;ClassThree&lt;/item&gt;
      &lt;item&gt;ClassFour&lt;/item&gt;
  &lt;/array&gt;
  </code></pre>
  
  <p>These are stored in an array, and passed to my MainActivityList adapter below:</p>
  
  <pre><code>String[] classes = resource.getStringArray(R.array.classes);
  MainActivityList adapter = new MainActivityList(titles,content, images, classes);
  recyclerView.setAdapter(adapter);
  </code></pre>
  
  <p>I've managed to add the OnClickListener to the ViewHolder and output what class is assigned to each view to the log, however I cannot figure out or get working, how to launch another activity.</p>
  
  <p>The class name would be something like ClassOne.class for example</p>
  
  <pre><code>public class MainActivityList extends RecyclerView.Adapter&lt;MainActivityList.ViewHolder&gt;  {
      private String[] mTitles;
      private String[] mContent;
      private String[] mClasses;
      private TypedArray mImages;
      private Context context;
  
      public MainActivityList(String[] titles, String[] content, TypedArray images, String[] classes) {
          this.mTitles = titles;
          this.mContent = content;
          this.mImages = images;
          this.mClasses = classes;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup viewGroup,int i) {
          final View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.activity_main_card, viewGroup, false);
          ViewHolder vh = new ViewHolder(v);
  
          v.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  ViewHolder vh = (ViewHolder)v.getTag();
                  Log.v("DEBUG", "Clicked" + vh.classes);
              }
          });
          return vh;
      }
  
      public void onBindViewHolder(ViewHolder holder, int position) {
          holder.titleView.setText(mTitles[position]);
          holder.contentView.setText(mContent[position]);
          holder.imageView.setImageDrawable(mImages.getDrawable(position));
          holder.classes = mClasses[position];
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public  TextView titleView;
          public  TextView contentView;
          public  ImageView imageView;
          public String classes;
  
          public ViewHolder(View v) {
              super(v);
              titleView = (TextView) v.findViewById(R.id.card_title);
              contentView = (TextView) v.findViewById(R.id.card_content);
              imageView = (ImageView)v.findViewById(R.id.card_image);
              v.setTag(this);
          }
      }
  
      @Override
      public int getItemCount() {
          return mTitles.length;
      }
  
  }
  </code></pre>