title: I want to create an OnClick event for cardview element i.e TextView to go to different activities through it. How can I create it?
body: <p>I am not getting how to go to different activities after clicking on the specific TextView which is inside the cardview. Below are the files of my project. ThankYou</p>
  
  <pre><code>ChemicalAdapter.java
  
      package com.example.tejask.chemilife_project;
  
  import android.support.v7.widget.CardView;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * Created by tejas k on 29-09-2015.
   */
  public class ChemicalAdapter extends RecyclerView.Adapter&lt;ChemicalAdapter.ViewHolder&gt;  {
  
      List&lt;NatureItem&gt;mItems;
  
      public ChemicalAdapter() {
          super();
          mItems = new ArrayList&lt;&gt;();
          NatureItem nature = new NatureItem();
          nature.setName("RO Chemicals");
          nature.setDes("Accepta's range of high performance reverse osmosis chemicals " +
                  "They are based on advanced formulations and include RO membrane cleaners and detergents," +
                  " scale inhibitors and antiscalants, corrosion inhibitors, biocides, antifoulants, de-chlorinators and flocculants.");
          mItems.add(nature);
  
          nature= new NatureItem();
          nature.setName("Boiler Chemicals");
          nature.setDes("This range of chemicals are “all in one boiler treatments” which incorporate a boiler water oxygen scavenger, alkalinity builder, polymer sludge conditioner and, where appropriate, a phosphate treatment. " +
                  "They are matched to the feed water quality to ensure that the correct boiler water chemistry is achieved.");
          mItems.add(nature);
  
          nature=  new NatureItem();
          nature.setDes(" Cooling Tower water chemical programs are effectively used for the reduction and prevention of the three major issues " +
                  "      your industrial cooling water system may encounter: corrosion, deposition, and microbial growth.");
          nature.setName("Cooling Tower Chemicals");
          mItems.add(nature);
  
          nature= new NatureItem();
          nature.setName("Sugar Processing Chemicals");
          nature.setDes("The Sugar cane processing chemicals are widely used in Sugar mills. They are used for processing," +
                  "Sugarcane in a handy way.Our company provides various types of Sugar Processing Chemicals at an affordable price");
          mItems.add(nature);
  
          nature= new NatureItem();
          nature.setName("Effuleant Treatment Chemicals");
          nature.setDes("We provide various types of Effuleant Treatment Chemicals");
          mItems.add(nature);
  
      }
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int i){
            View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_card_view, parent, false);
            ViewHolder viewHolder = new ViewHolder(v);
            return viewHolder;
        }
  
  
      @Override
      public void onBindViewHolder(ChemicalAdapter.ViewHolder viewHolder, int    position) {
          NatureItem nature = mItems.get(position);
          viewHolder.tvNature.setText(nature.getName());
          viewHolder.tvDesNature.setText(nature.getDes());
        //  viewHolder.tvDesNature.setOnClickListener(this);
         // viewHolder.imgThumbnail.setImageResource(nature.getThumbnail());
  
      }
  
      @Override
      public int getItemCount() {
          return mItems.size();
      }
  
        class ViewHolder extends RecyclerView.ViewHolder{
  
            //  public  ImageView imgThumbnail;
              public TextView tvNature;
              public TextView tvDesNature;
  
              public ViewHolder(View itemView){
                  super(itemView);
                  tvNature = (TextView) itemView.findViewById(R.id.tv_nature);
                  tvDesNature=(TextView)itemView.findViewById(R.id.tv_des_nature);      
  
  
              }
        }
  
      }
  
  This below class is for declaring getters and setters
      NatureItem.java
      package com.example.tejask.chemilife_project;
  
  /**
   * Created by tejas k on 29-09-2015.
   */
      public class NatureItem {
  
      private String Name;
      private String Des;
  
  
      public String getName() {
          return Name;
      }
  
      public void setName(String name) {
          Name = name;
      }
  
      public String getDes() {
          return Des;
      }
  
      public void setDes(String des) {
          Des = des;
      }
      }
  The below class is Activity where the CardViews are shown along with  RecyclerView.
  CardActivity.java
  package com.example.tejask.chemilife_project;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.Menu;
  import android.view.MenuItem;
  </code></pre>
  
  <p>/**
   * Created by tejas k on 29-09-2015.
   */
      public class CardActivity extends AppCompatActivity {</p>
  
  <pre><code>RecyclerView recyclerView;
  RecyclerView.LayoutManager layoutManager;
  RecyclerView.Adapter mAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.cardview);
      recyclerView= (RecyclerView) findViewById(R.id.recycler_view);
      recyclerView.setHasFixedSize(true);
  
      layoutManager= new LinearLayoutManager(this);
      recyclerView.setLayoutManager(layoutManager);
  
      mAdapter = new ChemicalAdapter();
      recyclerView.setAdapter(mAdapter);
  }
  
  }
  
  In below file I have declared the Recyclerview.
  
  cardview.xml
  &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:orientation="vertical"
  android:layout_height="match_parent"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginTop="20dp"
      android:layout_gravity="center"
      /&gt;&lt;/LinearLayout&gt;
  
  In the below file. I have declared the cardview along with Textview. It   serves as an UI for the activity.
  
  recycler_card_view.xml
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:orientation="vertical"
  android:background="#db7093"
  android:layout_height="match_parent"&gt;
  &lt;TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Click Them To Know Details"
      android:gravity="center"
      android:textSize="20dp"/&gt;
  &lt;android.support.v7.widget.CardView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      card_view:cardCornerRadius="3dp"
      android:layout_marginTop="15dp"
      android:layout_marginLeft="9dp"
      android:layout_marginRight="9dp"
      android:id="@+id/cardview"
      android:foreground="?android:attr/selectableItemBackground"
      card_view:cardElevation="0.01dp"
      android:layout_marginBottom="0dp"&gt;
  &lt;RelativeLayout
      android:id="@+id/top_layout"
      android:layout_width="fill_parent"
      android:layout_height="200dp"
      android:background="#db7093"&gt;
  &lt;TextView
      android:id="@+id/tv_nature"
      android:layout_width="fill_parent"
      android:layout_height="50dp"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:layout_gravity="bottom"
      android:gravity="center_vertical"
      android:background="#006666"
      android:alpha="0.8"
      android:textColor="#fff"
      android:textSize="26sp"
      android:text="Test"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true" /&gt;
      &lt;TextView
          android:layout_below="@+id/tv_nature"
          android:id="@+id/tv_des_nature"
          android:layout_width="match_parent"
          android:layout_height="125dp"
          android:textSize="22dp"
          android:onClick="true"
          android:textColor="#006666"/&gt;
    &lt;/RelativeLayout&gt;
    &lt;/android.support.v7.widget.CardView&gt;
    &lt;/LinearLayout&gt;
  </code></pre>