萨拉姆
如何检查Android AlertDialog
AlertDialog.Builder builder = new AlertDialog.Builder(A);
builder.setTitle(A.getString(R.string.which_number));
builder.setIcon(R.drawable.ic_launcher_mini);
builder.setMultiChoiceItems(line, null,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
}
});
答案 0 :(得分:9)
它可以帮到你吗?
AlertDialog.Builder builder = new AlertDialog.Builder(A);
builder.setTitle(A.getString(R.string.which_number));
builder.setIcon(R.drawable.ic_launcher_mini);
builder.setMultiChoiceItems(line, null,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
AlertDialog dialog = (AlertDialog) dialog;
ListView v = dialog.getListView();
int i = 0;
while(i < line.length) {
v.setItemChecked(i, check);
i++;
}
}
});
答案 1 :(得分:1)
setMultiChoiceItems的第二个输入参数是默认的CheckBoxes状态
int L = line.length;
boolean[] b2 = new boolean[L];
for(int i=0 ; i<L ; i++){
b2[i]=true;
}
builder.setMultiChoiceItems(line, b2,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {