0
protected CharSequence[] _options = { "English ", "Thai", "German", "Italy", "Spain", "All languages" };
protected boolean[] _selections = new boolean[ _options.length ];
@Override
protected Dialog onCreateDialog(int id)
{
return
new AlertDialog.Builder(this)
.setTitle("Choose Language")
.setMultiChoiceItems(_options, _selections, new DialogSelectionClickHandler())
.setPositiveButton("OK", new DialogButtonClickHandler())
.create();
}
public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
{
@Override
public void onClick(DialogInterface dialog, int clicked, boolean selected)
{
Log.i("ME", _options[ clicked ] + " selected: " + selected);
}
}
public class DialogButtonClickHandler implements DialogInterface.OnClickListener
{
@Override
public void onClick(DialogInterface dialog, int clicked)
{
switch(clicked)
{
case DialogInterface.BUTTON_POSITIVE:
printSelectedLanguage();
break;
}
}
}
protected void printSelectedLanguage(){
for(int i = 0; i < _options.length; i++){
Log.i("ME", _options[ i ] + " selected: " + _selections[i]);
}
}
我怎麼能檢查哪些複選框被選中關於複選框