我使用的是从apidemos以下code ..
I'm using the following code from the apidemos..
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.ic_popup_reminder)
.setTitle(R.string.alert_dialog_multi_choice)
.setMultiChoiceItems(R.array.select_dialog_items3,
new boolean[]{false, true, false, true, false, false, false},
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int whichButton,
boolean isChecked) {
/* User clicked on a check box do some stuff */
}
})
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked Yes so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked No so do some stuff */
}
})
.create();
在 / *用户点击的是这样做的一些东西* /
,我不喂的变量器isChecked。但是,我给在器isChecked的 / *用户点击一个复选框做一些东西* /
部分..很明显,我不想更新我的复选框,单击共享preFS,如果用户点击取消..
Under /* User clicked Yes so do some stuff */
, i'm not fed the isChecked variable.. however, I am given isChecked in the /* User clicked on a check box do some stuff */
section.. Obviously i don't want to update my SharedPrefs on checkbox click, in case the user hits cancel..
因此,我怎么得到的 setPositiveButton
的onClick的checkboxs和价值观?
So how do I get the checkboxs and values on the setPositiveButton
onClick ?
感谢。
推荐答案
传入 setMultiChoiceItems引用
。 字节[]
()
Pass a reference to byte[]
in setMultiChoiceItems()
.
final boolean[] booleans = {false, true, false, true, false, false, false};
然后检查布尔值
在 setPositiveButton()
。
如果你需要通过这个 AlertDialog
周围,然后扩展 AlertDialog
并创建一个字段布尔
如上述1。
If you need to pass this AlertDialog
around, then extend AlertDialog
and have create a field boolean
as described in 1.
相关推荐
最新文章