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);
I had the same problem. I just got rid of using,
mDrawerLayout.closeDrawer(Gravity.LEFT);
Answer:
mDrawerLayout.closeDrawer(mDrawerLayout);
had wrong Layout. so change in it with drawerlayout will work it out.