title: Android.widget.RelativeLayout cannot be cast to android.widget.ImageView
body: <p>I'm trying to get the instance of a ImageView defined in an XML layout file:</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/visual_compass_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/output_container" &gt;
  
      &lt;ImageView
          android:id="@+id/visual_compass"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:contentDescription="Compass"
          android:scaleType="fitStart"
          android:src="@drawable/compass_rose" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>But I always get that runtime error:</p>
  
  <pre><code>... java.lang.ClassCastException: android.widget.RelativeLayout cannot be
  cast to android.widget.ImageView ... at net.example.MainActivity.onCreate
  (MainActivity.java:57)
  </code></pre>
  
  <p>Line "57" is that one:</p>
  
  <pre><code>compassView = (ImageView) findViewById(R.id.visual_compass);
  </code></pre>
  
  <p>I can't figure out why that error ist thrown; I don't see the problem with that piece of code. Does anybody elso know?</p>
  
  <p>Thank you, Felix D.</p>