title: Android Custom Popup menu with switch
body: <p>How can I customize the menuItems in a popup menu? I need a switch for the first menuitem. Here is what I got so far:</p>
  
  <p><strong>menu.xml</strong></p>
  
  <pre><code>&lt;menu 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"
      tools:context="android.oli.com.fitnessapp.activities.LiveSelectActivity"&gt;
  
      &lt;item
          android:icon="@drawable/ic_access_alarm_white_24dp"
          android:orderInCategory="100"
          app:showAsAction="always"
          android:visible="true"
          android:title="@string/action_settings"
          android:onClick="showPopup"/&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p><strong>menu_popup.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item
          android:id="@+id/one"
          android:title="One"/&gt;
  
      &lt;item
          android:id="@+id/setTime"
          android:title="Two"
          android:onClick="showTimePickerDialog"/&gt;
  
  
  &lt;/menu&gt;
  </code></pre>
  
  <p><strong>Activity snippet</strong></p>
  
  <pre><code>public void showPopup(MenuItem menuItem){
          View view = findViewById(R.id.action_alarm);
          PopupMenu popup = new PopupMenu(this, view);
          MenuInflater inflater = popup.getMenuInflater();
          inflater.inflate(R.menu.menu_popup, popup.getMenu());
          popup.show();
      }
  </code></pre>