对话框类型Dialog

对话框类型

普通对话框

进度条对话框

单选对话框

 one.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

                builder.setIcon(R.mipmap.ic_launcher);
                builder.setTitle("提示方式");
               final String s[]=new String[]{"1","2"};
                builder
                        .setSingleChoiceItems(s, 0, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Toast.makeText(MainActivity.this, "111", Toast.LENGTH_SHORT).show();
                            }
                        }).setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "成功", Toast.LENGTH_SHORT).show();
                    }
                }).create().show();

            }
        });

多选对话框

  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);


                builder.setIcon(R.mipmap.ic_launcher);
                builder.setTitle("提示方式");
                final String s[]=new String[]{"1","2"};
                final boolean[] b=new boolean[]{true,false};
                builder
                        .setMultiChoiceItems(s, b, new DialogInterface.OnMultiChoiceClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which, boolean isChecked) {



                            }
                        }).create().show();

时间对话框

 Date date = new Date();
                int hour=date.getHours();
                int mm=date.getSeconds();
                TimePickerDialog timePickerDialog = new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                    }
                },hour,mm,true);
                timePickerDialog.show();

日期对话框


  Calendar calendar = Calendar.getInstance();
                int year=calendar.get(Calendar.YEAR);
                int mouth=calendar.get(Calendar.MONTH);
                int day=calendar.get(Calendar.DATE);

                DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {

                    }
                },year,mouth,day);
                datePickerDialog.show();

自定义对话框

自定义对框框需要创建一个小布局放入自定义的对话类让其显示然后对其进行自定义化

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值