Switch in Android navigation drawer
<p>Im trying to add a switch (checkbox as second option) to the navigation drawer. The &quot;slide in menu&quot;. The default one you'll get when creating a new project with navigation drawer.</p>
<p>I've tried on a fresh new project so I dont mess up my 'real' project.</p>
<p><a href="https://stackoverflow.com/questions/12107031/how-to-add-a-switch-to-android-action-bar">I tried this from SO</a></p>
<p>But without any luck. Cant seem to find anything else worth mentioning..</p>
<p>Im trying to add the switch at the last menuItem. activity_main_drawer.xml:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

&lt;group android:checkableBehavior=&quot;single&quot;&gt;
    &lt;item
        android:id=&quot;@+id/nav_camera&quot;
        android:icon=&quot;@drawable/ic_menu_camera&quot;
        android:title=&quot;Import&quot;
        android:checkable=&quot;true&quot;/&gt;
    &lt;item
        android:id=&quot;@+id/nav_gallery&quot;
        android:icon=&quot;@drawable/ic_menu_gallery&quot;
        android:title=&quot;Gallery&quot; /&gt;
    &lt;item
        android:id=&quot;@+id/nav_slideshow&quot;
        android:icon=&quot;@drawable/ic_menu_slideshow&quot;
        android:title=&quot;Slideshow&quot; /&gt;
    &lt;item
        android:id=&quot;@+id/nav_manage&quot;
        android:icon=&quot;@drawable/ic_menu_manage&quot;
        android:title=&quot;Tools&quot; /&gt;
&lt;/group&gt;

&lt;item android:title=&quot;Communicate&quot;&gt;
    &lt;menu&gt;
        &lt;item
            android:id=&quot;@+id/nav_share&quot;
            android:icon=&quot;@drawable/ic_menu_share&quot;
            android:title=&quot;Share&quot; /&gt;
        &lt;item
            android:id=&quot;@+id/nav_send&quot;
            android:icon=&quot;@drawable/ic_menu_send&quot;
            android:title=&quot;Send&quot; /&gt;
        &lt;item
            android:id=&quot;@+id/myswitch&quot;
            android:title=&quot;&quot;
            android:actionLayout=&quot;@layout/ttt&quot;
            /&gt;
    &lt;/menu&gt;
&lt;/item&gt;
&lt;/menu&gt;
</code></pre>
<p>ttt.xml</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
android:layout_width=&quot;fill_parent&quot;
android:layout_height=&quot;match_parent&quot;
android:orientation=&quot;horizontal&quot; &gt;

&lt;Switch
    android:id=&quot;@+id/ss&quot;
    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:text=&quot;&quot; /&gt;

&lt;/RelativeLayout&gt;
</code></pre>
<p>The last item &quot;id/myswitch&quot; doens't show at all.
The MainActivity.java is 100% default. Thats why I dont post it.</p>