title: LinearLayout cannot be cast to DrawerLayout
body: <p>I'm trying to add an image on top of the navigation drawer but every time I run it the application crash; the logcat gives me this error: <code>java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams</code></p>
  
  <p>Here is what I'm trying to do:</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  
      private DrawerLayout mDrawerLayout;
      private ListView mDrawerList;
      @SuppressWarnings("deprecation")
      private ActionBarDrawerToggle mDrawerToggle;
  
      private Menu mymenu;
  
      // nav drawer title
      private CharSequence mDrawerTitle;
  
      // used to store app title
      private CharSequence mTitle;
  
      // slide menu items
      private String[] navMenuTitles;
  
      private ArrayList&lt;NavDrawerItem&gt; navDrawerItems;
      private NavDrawerListAdapter adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mTitle = mDrawerTitle = getTitle();
  
          // load slide menu items
          navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
  
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
  
          navDrawerItems = new ArrayList&lt;NavDrawerItem&gt;();
  
          // adding nav drawer items to array
          // Home
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[0]));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[1]));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[2]));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[3]));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[4]));
          navDrawerItems.add(new NavDrawerItem(navMenuTitles[5]));
  
          // setting the nav drawer list adapter
          adapter = new NavDrawerListAdapter(getApplicationContext(), navDrawerItems);
          mDrawerList.setAdapter(adapter);
  
          // enabling action bar app icon and behaving it as toggle button
          getActionBar().setDisplayHomeAsUpEnabled(true);
          getActionBar().setHomeButtonEnabled(true);
  
          mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                  R.drawable.ic_drawer, //nav menu toggle icon
                  R.string.app_name, // nav drawer open - description for accessibility
                  R.string.app_name // nav drawer close - description for accessibility
          ){
              public void onDrawerClosed(View view) {
                  getActionBar().setTitle(mTitle);
                  // calling onPrepareOptionsMenu() to show action bar icons
                  invalidateOptionsMenu();
              }
  
              public void onDrawerOpened(View drawerView) {
                  getActionBar().setTitle(mDrawerTitle);
                  // calling onPrepareOptionsMenu() to hide action bar icons
                  invalidateOptionsMenu();
              }
          };
          mDrawerLayout.setDrawerListener(mDrawerToggle);
  
          if (savedInstanceState == null) {
              // on first time display view for first nav item
              displayView(1);
          }
  
          mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
      }
  
      /***
       * Called when invalidateOptionsMenu() is triggered
       */
      @Override
      public boolean onPrepareOptionsMenu(Menu menu) {
          // if nav drawer is opened, hide the action items
          //boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
          //menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
          return super.onPrepareOptionsMenu(menu);
      }
  
      @Override
      public void setTitle(CharSequence title) {
          mTitle = title;
          getActionBar().setTitle(mTitle);
      }
  
      /**
       * When using the ActionBarDrawerToggle, you must call it during
       * onPostCreate() and onConfigurationChanged()...
       */
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          // Sync the toggle state after onRestoreInstanceState has occurred.
          mDrawerToggle.syncState();
      }
  
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          // Pass any configuration change to the drawer toggls
          mDrawerToggle.onConfigurationChanged(newConfig);
      }
  
      /**
       * Slide menu item click listener
       * */
      private class SlideMenuClickListener implements
              ListView.OnItemClickListener {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
                  long id) {
              // display view for selected nav drawer item
              displayView(position);
          }
      }
  
       /**
       * Diplaying fragment view for selected nav drawer list item
       * */
      private void displayView(int position) {
          // update the main content by replacing fragments
          Fragment fragment = null;
          Bundle args = new Bundle();
          switch (position) {
          case 0:
              break;
          case 1:
              fragment = new HomeFragment();
              break;
          case 2:
              fragment = new PoliticaFragment();
              break;
          case 3:
              fragment = new GiustiziaFragment();
              break;
          case 4:
              fragment = new MediaFragment();
              break;
          case 5:
              fragment = new EconomiaFragment();
              break;     
          default:
              break;
          }
  
          /*if (fragment != null) {
              FragmentManager fragmentManager = getFragmentManager();
              fragmentManager.beginTransaction()
                      .replace(R.id.frame_container, fragment).commit();
  
              // update selected item and title, then close the drawer
              mDrawerList.setItemChecked(position, true);
              mDrawerList.setSelection(position);
              setTitle(navMenuTitles[position]);
              mDrawerLayout.closeDrawer(mDrawerList);
          } else {
              // error in creating fragment
              Log.e("MainActivity", "Error in creating fragment");
          }*/
  
          fragment.setArguments(args);
          FragmentManager frgManager = getFragmentManager();
          FragmentTransaction ft = frgManager.beginTransaction();
          ft.replace(R.id.frame_container, fragment).commit();
          mDrawerList.setItemChecked(position, true);
          setTitle(navMenuTitles[position]);
          mDrawerLayout.closeDrawer(mDrawerList);
      }
  
      @Override
      public void onBackPressed() {
  
          if(mDrawerLayout.isDrawerOpen(Gravity.LEFT)){
              mDrawerLayout.closeDrawer(Gravity.LEFT);
          }else{
              super.onBackPressed();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Add our menu
          getMenuInflater().inflate(R.menu.main, menu);
  
          // We should save our menu so we can use it to reset our updater.
          mymenu = menu;
  
          //
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Pass the event to ActionBarDrawerToggle, if it returns
          // true, then it has handled the app icon touch event
          if (mDrawerToggle.onOptionsItemSelected(item)) {
            return true;
          }
          // Handle your other action bar items...
  
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;!-- Framelayout to display Fragments --&gt;
      &lt;FrameLayout
          android:id="@+id/frame_container"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;!-- Listview to display slider menu --&gt;
  
        &lt;LinearLayout
         android:id="@+id/drawer"
         android:layout_width="240dp"
         android:layout_height="match_parent"
         android:orientation="vertical"
         android:layout_gravity="start" &gt;
  
            &lt;ImageView
                android:id="@+id/image_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/logo_il_fatto_quotidiano" /&gt;
  
      &lt;ListView
          android:id="@+id/list_slidermenu"
          android:layout_width="240dp"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:choiceMode="singleChoice"
          android:divider="@color/list_divider"
          android:dividerHeight="1dp"       
          android:listSelector="@drawable/list_selector"
          android:background="@color/list_background"/&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p><strong>NavDrawerItem.java</strong></p>
  
  <pre><code>public class NavDrawerItem {
      private String title;
  
      public NavDrawerItem(){}
  
      public NavDrawerItem(String title){
          this.title = title;
      }
  
      public String getTitle(){
          return this.title;
      }
  
      public void setTitle(String title){
          this.title = title;
      }
  }
  </code></pre>
  
  <p><strong>NavDrawerListAdapter.java</strong></p>
  
  <pre><code>public class NavDrawerListAdapter extends BaseAdapter {
      private Context context;
      private ArrayList&lt;NavDrawerItem&gt; navDrawerItems;
  
      public NavDrawerListAdapter(Context context, ArrayList&lt;NavDrawerItem&gt; navDrawerItems){
          this.context = context;
          this.navDrawerItems = navDrawerItems;
      }
  
      public int getCount() {
          return navDrawerItems.size();
      }
  
      public Object getItem(int position) {       
          return navDrawerItems.get(position);
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
          if (convertView == null) {
              LayoutInflater mInflater = (LayoutInflater)
                      context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
              convertView = mInflater.inflate(R.layout.drawer_list_item, null);
          }
  
          TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
  
          txtTitle.setText(navDrawerItems.get(position).getTitle());
  
          return convertView;
      }
  }
  </code></pre>
  
  <p><strong>string.xml</strong></p>
  
  <pre><code>    &lt;!-- Nav Drawer Menu Items --&gt;
      &lt;string-array name="nav_drawer_items"&gt;
          &lt;item&gt;Item 1&lt;/item&gt;
          &lt;item&gt;Item 2&lt;/item&gt;
          &lt;item&gt;Item 3&lt;/item&gt;
          &lt;item&gt;Item 4/item&gt;
          &lt;item&gt;Item 5&lt;/item&gt;
          &lt;item&gt;Item 6&lt;/item&gt;
      &lt;/string-array&gt;
  </code></pre>
  
  <p>Do you know where am I doing wrong? Thanks!</p>