title: android.widget.LinearLayout cannot be cast to android.widget.TextView in RecyclerView?
body: <p>I'm trying to list the data by using the new Recycler View. I've followed this <a href="https://developer.android.com/training/material/lists-cards.html#RecyclerView" rel="nofollow">tutorial</a> &amp; now facing issue at at one point.</p>
  
  <p>Here's my </p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.example.i.newworkspace;
  
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  
  
  public class MainActivity extends ActionBarActivity {
  
  TextView tv;
  RecyclerView recyclerView;
  RecyclerView.Adapter mAdapter;
  String[] myDataset = {"One","Two","Three","Four","Five"};
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
      recyclerView.setHasFixedSize(true);
      mAdapter = new MyAdapter(myDataset);
      recyclerView.setAdapter(mAdapter);
  
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  }
   class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt;
  
  {
      String[] mDataset;
  
      public static class ViewHolder extends RecyclerView.ViewHolder {
  
          public TextView mTextView;
          public ViewHolder(TextView v) {
              super(v);
              mTextView = v;
          }
      }
  
      @Override
      public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
          View v = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.my_text_view, null, false);
          ViewHolder vh = new ViewHolder((TextView) v);
          return vh;
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
  
          holder.mTextView.setText(mDataset[position]);
  
      }
  
      @Override
      public int getItemCount() {
          return mDataset.length;
      }
  
      MyAdapter(String[] myDataset) {
          mDataset = myDataset;
      }
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;
  
      &lt;android.support.v7.widget.RecyclerView
  
          android:id="@+id/recyclerview"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
      &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>my_text_view.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;TextView
          android:id="@+id/textView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code> java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
                  at com.example.i.newworkspace.MyAdapter.onCreateViewHolder(MainActivity.java:78)
                  at com.example.i.nuewworkspace.MyAdapter.onCreateViewHolder(MainActivity.java:59)
  </code></pre>
  
  <p>Line 78 : </p>
  
  <pre><code>        ViewHolder vh = new ViewHolder((TextView) v);
  </code></pre>