Intermittent error Unable to start activity... java.lang.classcastexception: android.widget.Relativelayout
<p>I have an annoying problem.
I suddenly started getting the above error for no apparent reason!</p>

<p>I narrowed it down to a specific part of my xml layout; strange thing is if I remove this part of the layout and then run the app then put it back and run the app again the error disappears!</p>

<p>My entire layout file is as follows:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
</code></pre>

<p></p>

<pre><code>&lt;RelativeLayout
    android:id="@+id/header"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    style="@style/HeaderBackground"&gt;

    &lt;ImageView
        android:id="@+id/headerIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/trailinfo_poi"
        style="@style/HeaderIcons"&gt;
    &lt;/ImageView&gt;
    &lt;TextView
        android:text="Item"
        android:id="@+id/itemTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@id/headerIcon"
        style="@style/Header"&gt;&lt;/TextView&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em></strong> OFFENDING PART HERE*<strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong></p>

<pre><code>&lt;RelativeLayout
    android:id="@+id/Option"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_below="@id/header"
    style="@style/OptionBackground"&gt;

    &lt;TextView
        android:text="text here"
        android:id="@+id/OptionTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        style="@style/text"
        android:layout_centerHorizontal="true"&gt;&lt;/TextView&gt;


    &lt;ImageButton
        android:id="@+id/optionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/not_ticked"
        android:layout_marginRight="10sp"
        android:onClick="optionClick"
        android:tag="no"&gt;
        &lt;/ImageButton&gt;


&lt;/RelativeLayout&gt;
</code></pre>

<p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em></strong> OFFENDING PART ENDS HERE <strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**</strong></p>

<pre><code>&lt;ImageView
    android:id="@+id/mainImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/Option"
    android:src="@drawable/nopoi"
    android:scaleType="fitXY"
    android:layout_centerHorizontal="true"
    style="@style/pageImage" /&gt;

&lt;ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/mainImage"
    android:layout_marginBottom="50sp"
    android:background="#FFFFFF"
    android:layout_margin="10sp"&gt;
    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:id="@+id/linearLayout1"
        android:layout_height="fill_parent"&gt;
        &lt;TextView
            android:text="TextView"
            android:id="@+id/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/mainImage"
            style="@style/blackTextText"&gt;&lt;/TextView&gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;
</code></pre>

<p></p>

<p>Can anyone see what the problem may be? As I don't understand why sometimes it happens and sometimes it doesn't??</p>

<p>Thanks</p>

<p>Bex</p>
