title: ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.LinearLayout
body: <p>I have some problems with this code.
  I'm trying to create a dynamically list of news with this format:</p>
  
  <hr>
  
  <pre><code>|image| - title
  |image|- subtitle
  </code></pre>
  
  <hr>
  
  <p>this is my little cicle code (a example with random data)</p>
  
  <pre><code>void setListNews(List&lt;Map&lt;String,String&gt;&gt;l){
          listaNewsPagina = l;
          final Iterator ite = listaNewsPagina.iterator();
          LinearLayout lin = (LinearLayout)findViewById(R.id.linear_sezione_news);
          LinearLayout lineare = (LinearLayout)findViewById(R.id.lineare);
          while(ite.hasNext()){
              Map&lt;String,String&gt; map = (Map&lt;String, String&gt;) ite.next();
              ImageView imm = (ImageView)findViewById(R.id.immagine);
              RelativeLayout rl = (RelativeLayout)findViewById(R.id.relative);
              TextView titolo = (TextView)findViewById(R.id.titolo);
              TextView sottoTitolo = (TextView)findViewById(R.id.sottoTitolo);
              titolo.setText("titolooooo");
              sottoTitolo.setText("sottoTitoloooooooooooo");
              rl.addView(titolo);
              rl.addView(sottoTitolo);
              lineare.addView(imm);
              lineare.addView(rl);
          }
          lin.addView(lineare);
              setContentView(lin);
  </code></pre>
  
  <p>and this is my layout:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/linear_sezione_news"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/background_homepage" &gt;
  
      &lt;LinearLayout
          android:id="@+id/lineare"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#aadd99"
           &gt;
  
          &lt;ImageView
              android:id="@+id/immagine"
              android:layout_width="50dp"
              android:layout_height="50dp"
              android:layout_marginBottom="4dp"
              android:layout_marginLeft="4dp"
              android:layout_marginRight="10dp"
              android:layout_marginTop="4dp"
              android:src="@drawable/ic_launcher" /&gt;
  
          &lt;RelativeLayout
              android:id="@+id/relative"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_marginBottom="4dp"
              android:layout_marginLeft="4dp"
              android:layout_marginRight="10dp"
              android:layout_marginTop="4dp"
              android:background="#abfc99"&gt;
  
          &lt;TextView
              android:id="@+id/titolo"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="20dp" /&gt;
          &lt;TextView
              android:id="@+id/sottoTitolo"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/titolo"
              android:textSize="13dp" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  
      &lt;ListView
          android:id="@+id/listViewNews"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_above="@+id/ImageButtonPrecc"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/lineare"
          android:alpha="0.8"
          android:background="#aadd99"
          android:clickable="true"
          android:padding="10dp"
          android:textAlignment="center" &gt;
  
      &lt;/ListView&gt;
  
      &lt;ImageButton
          android:id="@+id/ImageButtonPrecc"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_alignParentLeft="true"
          android:src="@drawable/bottone_prev"
          android:text="@string/load_news" /&gt;
  
      &lt;ImageButton
          android:id="@+id/ImageButtonSucc"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentRight="true"
          android:src="@drawable/bottone_next"
          android:text="@string/load_news" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>when I launch the activity with this code I have this problem:</p>
  
  <blockquote>
    <p>05-19 09:12:45.780: E/AndroidRuntime(21729): java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.LinearLayout</p>
  </blockquote>
  
  <p>I'm trying to create a layout with only Java code...but nothing XD
  where I'm wrong? </p>