MultiChoiceDialog
checkboxã§é¸æå¯è½ãªAlertDialogã®ä½ãæ¹
public class AlertDialogMultipulChoiceActivity extends Activity { String[] ar = { "red", "green", "bule", "white" , "apple" }; boolean[] bs = new boolean[ar.length]; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void onCLickButton(View v){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("choice"); builder.setMultiChoiceItems(ar, bs, new OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { Toast.makeText(AlertDialogMultipulChoiceActivity.this, ar[which] + ":" + isChecked, Toast.LENGTH_SHORT).show(); } }); builder.setPositiveButton("ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { StringBuilder sb = new StringBuilder(); for (boolean b : bs) { sb.append("" + b + System.getProperty("line.separator")); } TextView text = (TextView)findViewById(R.id.textview); text.setText(sb.toString()); } }); AlertDialog alert = builder.create(); alert.show(); } }