I want place TextView of bottom ListView in navigation drawer. Throws java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams
main.xml
<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"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="0dp"
android:paddingBottom="4dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="240dp"
android:layout_height="match_parent"
android:id="@+id/left_drawer"
android:layout_gravity="start"
>
<ListView
android:id="@+id/left_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:dividerHeight="0.1dp"
android:background="#111"
android:divider="#FFF"
/>
<TextView
android:id="@+id/joke_text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:lineSpacingExtra="5sp"
android:text="AAAAAA"
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
and java code:
// Getting reference to the DrawerLayout
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);
leftMenuItems = getResources().getStringArray(R.array.leftMenuItems);
mDrawerList = (ListView) findViewById(R.id.left_menu);
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// Generate title
String[] title = new String[] { "item1", "item2", "item4", "item4" };
// Generate icon
int[] icon = new int[] { R.drawable.abc_ic_clear, R.drawable.abc_ic_clear,
R.drawable.abc_ic_clear, R.drawable.abc_ic_clear };
MenuListAdapter adapter = new MenuListAdapter(this, title, icon);
// Setting the adapter on mDrawerList
mDrawerList.setAdapter(adapter);
// Getting reference to the ActionBarDrawerToggle
mDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
R.drawable.ic_drawer,
R.string.drawer_open,
R.string.drawer_close) {
public void onDrawerOpened(View drawerView) {
vstitle.setText("Menu");
invalidateOptionsMenu();
}
public void onDrawerClosed(View view) {
vstitle.setText("App");
invalidateOptionsMenu();
}
};
// Setting DrawerToggle on DrawerLayout
mDrawerLayout.setDrawerListener(mDrawerToggle);
I found some related topics, but it's not helpful for me