你好,我正在嘗試顯示一個帶複選框的警告對話框,以允許用戶選擇「不再顯示此對話框」選項。該對話框正在顯示,但複選框不顯示。這裏是我的代碼:android警報對話框中的android複選框沒有顯示
AlertDialog.Builder dialogBack;
dialogBack = new AlertDialog.Builder(this);
dialogBack.setTitle(context.getString(R.string.msg_attention));
dialogBack.setMessage(context.getString(R.string.msg_photo_caution));
dialogBack.setCancelable(false);
dialogBack.setPositiveButton(context.getString(R.string.confirm_continue),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBack, int which) {
dialogBack.dismiss();
beginTakeSupervisorPhoto();
}
});
dialogBack.setNegativeButton(context.getString(R.string.confirm_cancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBack, int which) {
dialogBack.dismiss();
}
});
final CharSequence[] items = {context.getString(R.string.msg_dont_show_again)};
dialogBack.setMultiChoiceItems(items, null,
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int indexSelected,boolean isChecked) {
Log.e("ListaClientesActivity.java","isChecked: "+isChecked);
if (isChecked) {
showPhotoWarning = false;
dataUtil.putBoolean(Constantes.SHOW_PHOTO_WARNING, false);
}else{
showPhotoWarning = true;
dataUtil.putBoolean(Constantes.SHOW_PHOTO_WARNING, true);
}
dataUtil.savePreferences();
}
});
dialogBack.create().show();
這很奇怪,因爲它的工作對我來說,當我使用的對話框文本視圖:
dialogBack.setView(myMsg);
是的我已經省略了該信息,現在顯示的複選框非常感謝 – adrian4aes
@ adrian4aes歡迎您也可以更新我的答案並添加一些代碼 –