title: How to add the button in a navigation Header in a navigation view?
body: <p>I created the navigation drawer in a main activity.I have added a switch in a navigation header in a navigation layout.I have created a separate layout for the navigation header.I don't know how to add the functionality for the switch.How can I make the switch on and off for doing any functions.</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_dash_board"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.seyali.calllogs.DashBoardActivity"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          &gt;
          &lt;include
              android:layout_height="wrap_content"
              android:layout_width="match_parent"
              layout="@layout/toolbar_layout"
              &gt;
  
          &lt;/include&gt;
      &lt;/LinearLayout&gt;
  
  
      &lt;android.support.design.widget.NavigationView
  
          android:layout_height="match_parent"
          android:layout_width="match_parent"
          android:id="@+id/navigation_View"
          android:layout_gravity="start"
          app:menu = "@menu/drawer_menu"
          app:headerLayout="@layout/navigation_drawer_header"&gt;
      &lt;/android.support.design.widget.NavigationView&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>The below code is for navigation header layout.I added switch and the textview in a navigation header.navigation_drawer_header.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="200dp"
      android:background="@drawable/backgroung_red_colour"&gt;
      &lt;Switch
          android:text="Call Recording"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/navigation_drawer_switch"
          android:layout_alignParentBottom="true"
          android:gravity="left"
          android:textOff="off"
          android:textOn="on"/&gt;
  
      &lt;TextView
          android:text="Switch"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/navigation_drawer_switch"
          android:layout_alignParentStart="true"
          android:layout_marginBottom="28dp"
          android:id="@+id/drawertext" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>