title: Set checkboxes status in Multichoice AlertDialog in Android
body: <p>Following is my code for my <code>AlertDialog.Builder</code></p>
  
  <pre><code>    final String[] values = new String[] {"Select All", "Android", "ios", "windows", "Blackberry"};
      final ArrayList&lt;String&gt; selecteditems = new ArrayList&lt;String&gt;();
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle("Select your favorite OS");
        builder.setMultiChoiceItems(values, null , new DialogInterface.OnMultiChoiceClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which, boolean isChecked) {
  
              if (isChecked) {
                  selecteditems.add(String.valueOf(which));
  
              } else {
  
                  selecteditems.remove(Integer.valueOf(which));
              }
          }
      })
      .setPositiveButton("OK", new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
  
          }
      })
      .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
             dialog.dismiss();
  
          }
      });
  
      AlertDialog dialog = builder.create();
      dialog.show();
  </code></pre>
  
  <p>What I want to do is to be able to detect when 'Select All' is checked, which I can from the <code>isChecked</code> loop. But I want to be able to set all the options to checked when the user checks 'Select All' and remove the checks when user unchecks 'Select All'.</p>