title: Android: java.lang.ClassCastException: android.widget.imageView cannot be cast to android.widget.textView
body: <p>I can't fix this problem on my listview template: i have the error as in the title of my post, but i won't cast imageview to textview. Here's my code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="200dip"
  android:layout_weight="1"
  android:paddingBottom="10dip" &gt;
  
  &lt;TextView
      android:id="@+id/mq"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:text="Metri quadri"
      android:textColor="#33b5e5"
      android:textSize="14sp"
      android:textStyle="bold" /&gt;
  
  &lt;TextView
      android:id="@+id/citta"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/mq"
      android:layout_alignBottom="@+id/mq"
      android:layout_centerHorizontal="true"
      android:text="Citta"
      android:textColor="#33b5e5"
      android:textSize="14sp"
      android:textStyle="bold" /&gt;
  
  &lt;TextView
      android:id="@+id/prezzo"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:text="Prezzo"
      android:textColor="#e1e1e1"
      android:textSize="14sp"
      android:textStyle="bold" /&gt;
  
  &lt;TextView
      android:id="@+id/nome"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:padding="5dip"
      android:scrollHorizontally="true"
      android:singleLine="true"
      android:text="@string/testolungo"
      android:textColor="#e1e1e1"
      android:textSize="20sp"
      android:textStyle="bold" /&gt;
  
  &lt;ImageView
      android:id="@+id/foto"
      android:layout_width="80dip"
      android:layout_height="60dip"
      android:layout_alignParentLeft="true"
      android:layout_centerVertical="true"
      android:contentDescription="Release"
      android:padding="5dip"
      android:scaleType="centerCrop"
      android:src="@drawable/stub" /&gt;
  
  &lt;TextView
      android:id="@+id/descsplash"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:text="Small Text"
      android:textSize="16sp"
      android:textStyle="italic" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The error for the java code is on line 58 of my file, where i assign the TextView id to TextView mq:</p>
  
  <pre><code>    View vi=convertView;
      if(convertView==null)
      vi = inflater.inflate(R.layout.listlay, null);
      TextView nome=(TextView)vi.findViewById(R.id.nome);
      TextView mq=(TextView)vi.findViewById(R.id.mq); // here's the error (???)
      TextView citta=(TextView)vi.findViewById(R.id.citta);
      TextView prezzo=(TextView)vi.findViewById(R.id.prezzo);
      ImageView image=(ImageView)vi.findViewById(R.id.foto);
      TextView descrizione = (TextView)vi.findViewById(R.id.descsplash);
      nome.setText(data.get(position).getNome());
      mq.setText(data.get(position).getMetriQuadri());
      citta.setText(data.get(position).getCitta());
      prezzo.setText(data.get(position).getPrezzo());
      descrizione.setText(data.get(position).getDescrizione());
      imageLoader.DisplayImage(data.get(position).getForoUrl(), image);
  </code></pre>
  
  <p>And here is the logcat:</p>
  
  <blockquote>
    <p>06-25 16:08:32.497: D/Debug(14642): Prendo Textview MQ<br>
    06-25 16:08:32.497: D/AndroidRuntime(14642): Shutting down VM<br>
    06-25 16:08:32.497: W/dalvikvm(14642): threadid=1: thread exiting with uncaught exception (group=0x40a561f8)<br>
    06-25 16:08:32.497: E/AndroidRuntime(14642): FATAL EXCEPTION: main<br>
    06-25 16:08:32.497: E/AndroidRuntime(14642): java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.TextView<br>
    06-25 16:08:32.497: E/AndroidRuntime(14642): at com.prova.listview.LazyAdapter.getView(LazyAdapter.java:58)</p>
  </blockquote>
  
  <p>Does anyone know how i can fix this problem?</p>