title: I cant get my dialog check box to work in android studio
body: <p>Im trying to have a button that says "choose drink" when the user clicks the button a dialog appears with a list of drinks that i have stored in an array.</p>
  
  <p>I know the problem is where ive said "boolean is checked" but I need that because my items are stored in an array. someone help please!
  if i remove boolean is checked then i obviously get an error on the if statement where it says "isChecked"</p>
  
  <pre><code>package com.example.liamchowney.myappoctober;
  
  
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.support.v4.app.DialogFragment;
  import android.app.Dialog;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.ArrayList;
  
  
  
  
  public class Multiselection extends DialogFragment {
  
  private static TextView text_view;
  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); //to store selection
  
  @Override
  @NonNull
  public Dialog onCreateDialog(Bundle savedInstanceState)
  {
      final String [] items = getResources().getStringArray(R.array.my_drinks_selection); //gets array items to screen
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setTitle("Choose drink").setSingleChoiceItems(R.array.my_drinks_selection, null, new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which, boolean isChecked) {
  
              if(isChecked)
              {
                  list.add(items[which]); //adds selected item
              }
              else if(list.contains(items[which]))
              {
                  list.remove(items[which]); //removes selected item if they uncheck
              }
  
          }
      }).setPositiveButton("OK", new DialogInterface.OnClickListener() { //to display the selected item done by user
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              String selections = ""; //default value
              for(String ms : list)
              {
                  selections = selections + "\n" +ms;
              }
              Toast.makeText(getActivity(), "Drink Selection :" +selections, Toast.LENGTH_LONG).show();
  
          }
      });
      return builder.create();
     }
  }
  </code></pre>