0

Can someone help me with this error ?

XDA Developer thread

I want to use navigation drawer ...but not simple one. but similar to this one

enter image description here

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 ?

user3264399
  • 284
  • 1
  • 13
user3278732
  • 1,694
  • 10
  • 31
  • 67

3 Answers3

1

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.

Greg Ennis
  • 14,917
  • 2
  • 69
  • 74
  • how can I do that? That is have inside onelistview multiple headers. header below it item 1 item 2... then header 2 below it item 3 item 4 item 5... all one listview – user3278732 Feb 06 '14 at 09:38
1

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"/>
Lokesh
  • 5,180
  • 4
  • 27
  • 42
1

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);
Namrata
  • 1,683
  • 1
  • 17
  • 28