ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams

What solved this issue for me:

In MainActivity, add a new field for the LinearLayout, and assign value to it in onCreate() (this part just like emaleavil suggested):

private LinearLayout linearLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // ...
    linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
}

Then in selectItem(), when calling closeDrawer(), simply pass linearLayout as argument:

drawerLayout.closeDrawer(linearLayout);

Leave a Comment