首页 > 其他分享 >点击弹出日期对话框

点击弹出日期对话框

时间:2022-12-12 13:23:31浏览次数:50  
标签:对话框 int DatePickerDialog 日期 点击 viewById new datePickerDialog

        //按钮事件
        findViewById(R.id.btn_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                DatePickerDialog datePickerDialog = new DatePickerDialog(DatePickerActivity.this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                        @SuppressLint("DefaultLocale")
                        String desc = String.format("你选择的日期是%d年%d月%d日", i, i1 + 1,i2);
                        TextView viewById = findViewById(R.id.tv_date);
                        viewById.setText(desc);
                    }
                }, 2022, 12, 12);
                datePickerDialog.show();
            }
        });

标签:对话框,int,DatePickerDialog,日期,点击,viewById,new,datePickerDialog
From: https://www.cnblogs.com/loulan/p/16975786.html

相关文章