1

I have this Dialog with 4 items in it. And I need to make for example first item unselectable (unclickable), how can I do that?

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();
4

1 回答 1

0

in your xml make this for the widget you don't want it to be clickable

android:clickable="false"
于 2013-04-07T16:02:09.660 回答