I am trying to add a switch (checkbox as second option) to the navigation box. "Slide in the menu." By default, you will receive when creating a new project using the navigation box.
I tried a new new project, so I did not ruin my "real" project.
I tried this from SO
But no luck. Can't find anything else worth mentioning.
I am trying to add a switch to the last menu item. activity_main_drawer.xml:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_camera" android:icon="@drawable/ic_menu_camera" android:title="Import" android:checkable="true"/> <item android:id="@+id/nav_gallery" android:icon="@drawable/ic_menu_gallery" android:title="Gallery" /> <item android:id="@+id/nav_slideshow" android:icon="@drawable/ic_menu_slideshow" android:title="Slideshow" /> <item android:id="@+id/nav_manage" android:icon="@drawable/ic_menu_manage" android:title="Tools" /> </group> <item android:title="Communicate"> <menu> <item android:id="@+id/nav_share" android:icon="@drawable/ic_menu_share" android:title="Share" /> <item android:id="@+id/nav_send" android:icon="@drawable/ic_menu_send" android:title="Send" /> <item android:id="@+id/myswitch" android:title="" android:actionLayout="@layout/ttt" /> </menu> </item> </menu>
ttt.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="horizontal" > <Switch android:id="@+id/ss" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </RelativeLayout>
The last id / myswitch is not displayed at all. MainActivity.java is 100% by default. That is why I do not publish it.
source share