title: Cannot cast View to <fragment>
body: <p>In my xml I have the following code:</p>
  
  <pre><code>    &lt;fragment android:name="somepackage.Fragments.ToolbarFragment"
      android:id="@+id/toolbar_fragment"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/&gt;
  </code></pre>
  
  <p>and in my code I have:</p>
  
  <pre><code>private ToolbarFragment toolbarFragment;
  toolbarFragment = (ToolbarFragment) findViewById(R.id.toolbar_fragment);
  </code></pre>
  
  <p>I receive the error: "cannot cast android.view.View to somepackage.Fragments.ToolbarFragment"</p>
  
  <p>why is android seeing the fragment as a generic view type instead of as the fragment class that I specified? </p>