0

Similar to how Gmail does it, I would like to add a text divider to my navigation drawer after the (in my case) second item. How can I achieve that? I guess somewhere around

mDrawerAdapter = new DrawerAdapter(this, cursor);

        mDrawerList.post(new Runnable() {
            public void run() {
                mDrawerList.setAdapter(mDrawerAdapter);
                selectDrawerItem(mCurrentDrawerPos);
            }
        });

, right?

Thanks! enter image description here

Made by FA
  • 710
  • 2
  • 7
  • 27

2 Answers2

0

Could you post your menu.xml file ?

Otherwhise to display separator you need to create groups like this :

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group
        android:id="@+id/first_group"
        android:checkableBehavior="single">
        <item
            android:checked="true"
            android:id="@+id/item1"
            android:icon="@drawable/XX"
            android:title="@string/XXX"/>
        <item
            android:id="@+id/item2"
            android:icon="@drawable/XXX"
            android:title="@string/XXX"/>
    </group>

    <group
        android:id="@+id/second_group"
        android:checkableBehavior="none">
        <item
            android:id="@+id/item3"
            android:icon="@drawable/XXX"
            android:title="@string/XXX" >
        </item>
    </group>
</menu>
Kévin Giacomino
  • 487
  • 4
  • 11
0

You have a couple of options form where I sit.

  1. Use a separate layout file for this view which would mean having more than one model type of data backing your Adapter and inflating the correct layout depending on the type. See here
  2. Use Item decoration to add a line to the bottom of a chosen layout or layouts. this post should help
Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34