0

I am creating an Android application where I have to have Navigation drawer style. I am having the latest Android SDK, deploy. target is 4.4.2 and Eclipse environment. When I created project, it allowed me to choose Navigation drawer, so automatically the project created Navigation drawer nicely with 3 sample sections (section 1, 2 and 3) default added. But, I want to have header for each section. Attached is the image for reference, where we can see headers like "Accounts and Tasks", "Life Events" etc. I have seen some reference and they are saying to add ListView in this Navigation drawer to get headers. I don't understand, how it is possible etc.

Could someone please guide me to achieve getting Headers in Navigation drawer style. Anyone please?

enter image description here

Stella
  • 1,728
  • 5
  • 41
  • 95
  • Please don't prefix your questions titles with tag words like android, ios etc, the tags at the bottom are enough to specify the target. I don't know the output of the generated project but what you need is a `ListView` as the drawer content and to that list set an adapter which has sections at the desired levels. – user Jun 04 '14 at 12:32

2 Answers2

0

I think the general NavDrawer example uses a listview as its content (assuming you are too).

If you are using a ListView to create that content, you can add a ListView header, to contain the content you would like: Docs: http://developer.android.com/reference/android/widget/ListView.html#addHeaderView

SO: Using ListView : How to add a header view?

Community
  • 1
  • 1
Booger
  • 18,579
  • 7
  • 55
  • 72
0

I fixed same problem. I'am usign Android Studio but same codes.

Lisview object should get into Linealayout/Relativelayout

Now to do what you want usual

Sample :

<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
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="250dp"
        android:layout_height="fill_parent"
        android:layout_gravity="left"
        android:id="@+id/left_drawer"
        android:background="@color/app_white">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/left_drawer_about_padding">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView"
                    android:src="@drawable/bulenttiras"/>
            </LinearLayout>

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="@dimen/left_drawer_about_padding">

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:text="@string/menu_title"
                    android:id="@+id/textView"/>
            </LinearLayout>
        </LinearLayout>

        <ListView
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:id="@+id/navigation_list" />
    </LinearLayout>


</android.support.v4.widget.DrawerLayout>

Hope can help you. My english weak, so sorry. Good luck

Olkunmustafa
  • 3,103
  • 9
  • 42
  • 55