我有一个显示复选框列表的对话框。我想在每次显示对话框时设置不同的框。但这仅在第一次有效..我希望每次显示对话框时都能正常工作!如果有人可以提供帮助,那就太好了...
这是我的代码:
@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();
}