0
我想弄清楚如何以编程方式选中我的复选框对话框代码,我已经设置了我的复选框。复选框对话框以编程方式选择
我将如何以编程方式从我的onClick方法下方切换我的复选框。
如果有人可以看看我的代码到目前为止,并给我一些指导,那会很好。
代码:
AlertDialog dialog;
final CharSequence[] items = { "All listings", "Buy it now",
"Auction", "Nearest first" };
final ArrayList<Integer> seletedItems = new ArrayList<Integer>();
final SharedPreferences shfObject = getActivity()
.getSharedPreferences("NAME", Context.MODE_PRIVATE);
final SharedPreferences.Editor shfEditorObject = shfObject.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Filter");
builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog,
final int indexSelected, boolean isChecked) {
if (isChecked) {
}
}
})
// Set the action buttons
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
// Your code when user clicked on Cancel
}
});
dialog = builder.create();// AlertDialog dialog; create like this
// outside onClick
dialog.show();
你不知道的 'checkBox.setChecked(真);'或者我没有正确地得到你的问题? – Darpan