本文介绍了如何检查 AlertDialog 中的所有复选框项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

萨拉姆
如何在 Android AlertDialog 中检查所有复选框项目(setMultiChoiceItems)

salam
How check all Checkbox items(setMultiChoiceItems) in 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) {
                }
            });

推荐答案

能帮到你吗?

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++;
                    }
                }
            });

这篇关于如何检查 AlertDialog 中的所有复选框项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:04