Can someone help me with this error ?
I want to use navigation drawer ...but not simple one. but similar to this one
How can I have list of items below it item 1 item 1, then have header list of houses house house 2 house 3 below it ?
Can someone help me with this error ?
I want to use navigation drawer ...but not simple one. but similar to this one
How can I have list of items below it item 1 item 1, then have header list of houses house house 2 house 3 below it ?
Navigation drawer only supports one listview. However, you can support headers within your list view using the standard Android ListView
class. You need to override getItemViewType
and getViewTypeCount
to supply different view types. In your case, you would have one type (layout) for the header and one for the list items.
I think problem with height of first list view:
try this:
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="wrap_content"
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"/>
<ListView
android:id="@+id/list_menuslider"
android:layout_width="240dp"
android:layout_height="wrap_content"
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"/>
Write this code in new xml for header name it list_header
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="50dp"
android:background="@drawable/welcome_text_bg" >
<TextView
android:id="@+id/txt_slider_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="...................."
android:textColor="@color/red"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
Write following code to your Activity:-
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
LayoutInflater inflater = getLayoutInflater();
ViewGroup mTop = (ViewGroup) inflater.inflate(
R.layout.header_listview_menue, mDrawerList, false);
mDrawerList.addHeaderView(mTop, null, false);
txt_slider_user = (TextView) findViewById(R.id.txt_slider_user);