Dialog中的单选事件setSingleChoiceItems

case R.id.tv_atools_select_bg:
            Log.i(TAG, "dianjiggggggggg");
            AlertDialog.Builder builder=new Builder(this);
            builder.setTitle("归属地提示显示风格");
            String[] items=new String[]{"半透明","活力橙","苹果绿"};
            int background= sp.getInt("background", 0);
            //保存之前选择颜色的状态
            builder.setSingleChoiceItems(items, background, new DialogInterface.OnClickListener(){

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Editor editor=sp.edit();
                    editor.putInt("background", which);
                    editor.commit();
                }});
            builder.setPositiveButton("确定", new DialogInterface.OnClickListener(){

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }});
            builder.create().show();
            break;

Dialog中的单选事件setSingleChoiceItems_第1张图片

你可能感兴趣的:(控件)