title: LinearLayout cannot be cast to android.widget.checkbox
body: <p>The problem that I am facing is that my app <strong>crashes at launch</strong> with the above error when the following statement is included.</p>
  
  <pre><code>  external= (CheckBox) menu.findItem(R.id.location).getActionView();
  </code></pre>
  
  <p>The code block with this statement is</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
      // TODO Auto-generated method stub
      new MenuInflater(this).inflate(R.menu.actions,menu);
      Log.d("Action","inflated");
      external= (CheckBox) menu.findItem(R.id.location).getActionView();   &lt;&lt;&lt;error
      Log.d("Action","external initialized");
      return super.onCreateOptionsMenu(menu);
  }
  </code></pre>
  
  <p><em><strong>external</em></strong> is a data member of the same class declared as</p>
  
  <pre><code>private CheckBox external=null;
  </code></pre>
  
  <p>The menu that is inflated is : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  &lt;item 
       android:id="@+id/location"
       android:actionLayout="@layout/action_location"
       android:showAsAction="never"&gt;
  
  &lt;/item&gt;
  &lt;item 
      android:id="@+id/save" 
      android:title="Save" 
      android:showAsAction="always"&gt;
  
  &lt;/item&gt;
  &lt;item 
      android:id="@+id/saveBackground" 
      android:showAsAction="always|withText"
      android:title="in BG"&gt;
  
  &lt;/item&gt;
  </code></pre>
  
  <p></p>
  
  <p>If that particular line is commented out, the app launches just fine. What could be the issue ? </p>
  
  <p>[UPDATE]  Here's the action_location.xml content</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  &lt;CheckBox 
      android:id="@+id/external"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:title="@string/external"
      /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>