content: package com.amatellanes.android;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.support.v4.app.DialogFragment;
  
  public class MultipleChoiceListDialog extends DialogFragment {
  
  	private List<Integer> mSelectedItems;
  
  	@Override
  	public Dialog onCreateDialog(Bundle savedInstanceState) {
  		mSelectedItems = new ArrayList<Integer>(); // Where we track the
  													// selected items
  		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  		// Set the dialog title
  		builder.setTitle("Selecciona varios colores...")
  				// Specify the list array, the items to be selected by default
  				// (null for none),
  				// and the listener through which to receive callbacks when
  				// items are selected
  				.setMultiChoiceItems(R.array.array_colors, null,
  						new DialogInterface.OnMultiChoiceClickListener() {
  							@Override
  							public void onClick(DialogInterface dialog,
  									int which, boolean isChecked) {
  								if (isChecked) {
  									// If the user checked the item, add it to
  									// the selected items
  									mSelectedItems.add(which);
  								} else if (mSelectedItems.contains(which)) {
  									// Else, if the item is already in the
  									// array, remove it
  									mSelectedItems.remove(Integer
  											.valueOf(which));
  								}
  							}
  						})
  				// Set the action buttons
  				.setPositiveButton(android.R.string.ok,
  						new DialogInterface.OnClickListener() {
  							@Override
  							public void onClick(DialogInterface dialog, int id) {
  								// User clicked OK, so save the mSelectedItems
  								// results somewhere
  								// or return them to the component that opened
  								// the dialog
  							}
  						})
  				.setNegativeButton(android.R.string.cancel,
  						new DialogInterface.OnClickListener() {
  							@Override
  							public void onClick(DialogInterface dialog, int id) {
  
  							}
  						});
  
  		return builder.create();
  	}
  }
  