title: How to use CheckBox in the menu in Android?
body: <p>I am new to Android. I want to use a checkbox in the menu which has to be checked and unchecked while the user touching. And I need to perform some actions if the check box is checked. Right now I have a checkbox that is checked when the program is run.</p>
  
  <p>I have managed to insert checkbox in the menu and got it to be checked when the app starts, just as it should. But when I try to uncheck it, the program crashes.</p>
  
  <p>Menu.xml:</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
          &lt;item
              android:id="@+id/checkBox1"
              android:showAsAction="never"
              android:title="Allow Check"
              android:checkable="true"
              android:checked="true" /&gt;
  
          &lt;item
              android:id="@+id/action_help"
              android:orderInCategory="100"
              android:showAsAction="never"
              android:title="Hai"/&gt;
  
          &lt;item
               android:id="@+id/checkBox2"
               android:showAsAction="never" 
               android:title="Allow Check 2" 
               android:checkable="true"
               android:checked="true" /&gt;
      &lt;/menu&gt;
  </code></pre>
  
  <p>MainActivity.cs</p>
  
  <pre><code>    public override bool OnCreateOptionsMenu (IMenu menu)
      {
          base.OnCreateOptionsMenu (menu);
          MenuInflater inflater = this.MenuInflater;
          inflater.Inflate (Resource.Menu.menu, menu);
      return true;
              }
  
      public override bool OnOptionsItemSelected (Android.Views.IMenuItem item)
      {
          switch (item.ItemId) {
              case Resource.Id.action_help:
                  return true;
              case Resource.Id.checkBox1:
                  CheckBox check1 = (CheckBox)FindViewById (Resource.Id.checkBox1);
  //Here the check1 come as null, which leads to the crash.
                  if (check1.Checked == true)
                      check1.Checked = false;
                  else
                      check1.Checked = true;
                  check1.Click += check1_Click;
                  return true;
              case Resource.Id.checkBox2:
                  CheckBox check2 = (CheckBox)FindViewById (Resource.Id.checkBox2);
                  if (check2.Checked == true)
                      check2.Checked = false;
                  else
                      check2.Checked = true;
                  check2.Click += check2_Click;
                  return true;
  
                  default:
                      return base.OnOptionsItemSelected (item);
                  }
          }
  </code></pre>
  
  <p>While trying to retrieve the checkbox declared in the menu, it comes as null. How can I get this working?</p>