Android setMultiChoiceItems和setMessage not";“工作”;在AlertDialog中

Android setMultiChoiceItems和setMessage not";“工作”;在AlertDialog中,android,android-alertdialog,Android,Android Alertdialog,我很困惑为什么我的对话框不能正常工作: AlertDialog dialog; final AlertDialog.Builder builder = new AlertDialog.Builder(this); final CharSequence[] confirmCheckbox = {"Delete the SQLite database upon exit."}; final boolean states[] = {false}; builder.setTitle("Delete

我很困惑为什么我的对话框不能正常工作:

AlertDialog dialog;
final AlertDialog.Builder builder = new AlertDialog.Builder(this);  
final CharSequence[] confirmCheckbox = {"Delete the SQLite database upon exit."};
final boolean states[] = {false};

builder.setTitle("Delete Database on Exit?");
builder.setMultiChoiceItems(confirmCheckbox, states, new DialogInterface.OnMultiChoiceClickListener(){
    public void onClick(DialogInterface dialogInterface, int item, boolean state) {
    }
}).setMessage("Check the checkbox below to confirm that you wish to delete the SQLite database upon exit.\n" +
        "To cancel this action, hit the back button.")
.setPositiveButton(R.string.confirm_button_text, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {
        dialog.cancel();
    }
});
dialog = builder.create();
//dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); <-- This will fail. BUTTON_POSITIVE is NULL
dialog.show();
AlertDialog;
final AlertDialog.Builder=新建AlertDialog.Builder(此);
final CharSequence[]confirmCheckbox={“退出时删除SQLite数据库”。};
最终布尔状态[]={false};
setTitle(“在退出时删除数据库?”);
setMultiChoiceItems(confirmCheckbox,states,new DialogInterface.OnMultiChoiceClickListener()){
public void onClick(DialogInterface,int项,布尔状态){
}
}).setMessage(“选中下面的复选框,确认您希望在退出时删除SQLite数据库。\n”+
“要取消此操作,请单击“上一步”按钮。”)
.setPositiveButton(R.string.confirm_按钮_文本,新的DialogInterface.OnClickListener(){
public void onClick(DialogInterface对话框,int-id){
dialog.cancel();
}
});
dialog=builder.create();

//dialog.getButton(AlertDialog.BUTTON_正值)。setEnabled(false);那是因为它们不兼容。在AlertDialog上设置项目后,该对话框将不再包含消息。找不到教我这一点的参考资料,但在一年多前遇到了这个问题,我自己那么我会用什么来代替呢?文档使用AlertDialogs您是否尝试过使用自定义布局?我认为这是一个选项,但如果不需要的话,我不想重新发明轮子。我希望做一些类似于文档的工作会奏效。我可能会这样做。另外,我最初错误地认为正负按钮不兼容。这仅适用于单选项,但多选项确实适用于正/负按钮