如何在Dialog中使某些项目无法选择?

时间:2013-04-07 15:44:21

标签: android dialog unselect

我有这个Dialog,里面有4个项目。我需要制作第一个项目不可选(不可点击),我该怎么做?

String[] presets = { getString(R.string.string1), getString(R.string.string2), getString(R.string.string3), getString(R.string.string4) };
            AlertDialog dialog;
            AlertDialog.Builder builder = new AlertDialog.Builder(ListFragment.this.getActivity());
            builder.setTitle(name);
            builder.setItems(presets, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int position1) {
                    switch(position1) {
                    case 0:
                        //some code
                        break;
                    case 1:
                        //some code
                        break;
                    case 2:
                        //some code
                        break;
                    case 3:
                        //some code
                        break;
                    }
                    dialog.dismiss();
                }
            });
            dialog = builder.create();
            dialog.show();

1 个答案:

答案 0 :(得分:0)

在你的xml中为你不想让它点击的小部件做这个

android:clickable="false"