J'ai une boîte de dialogue qui affiche une liste de checkBoxes. Je voudrais définir différentes cases cochées chaque fois que la boîte de dialogue est affichée. Mais cela ne marche que la première fois .. Je veux que ça fonctionne à chaque fois que le dialogue est affiché! Ce serait formidable si quelqu'un peut aider ...Définir les cases cochées pour une boîte de dialogue checkBox-list
Ceci est mon code:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case CHECKBOX_LIST_DIALOG:
final CharSequence[] weeks = new CharSequence[53];
for (int i=0; i<=52; i++) {
weeks[i] = String.valueOf(i+1);
}
return new AlertDialog.Builder(this).setTitle(
R.string.txt_week_checkbox_list).setMultiChoiceItems(
weeks, getCheckedBoxes(),
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) {
checked[whichButton] = isChecked;
}
}).setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
EditText editText = (EditText) findViewById(R.id.edittext_weeks);
editText.setText(generateString());
}
}).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
}
}).create();
}