Android: DatePicker and DatePicker Dialog

前端 未结 8 549
梦如初夏
梦如初夏 2020-12-24 09:23

I have this code here on the options menu

Dialog dialog = new Dialog(ScheduleActivity.this);
dialog.setTitle(\"Add Event\");
dialog.setContentView(R.layout.         


        
8条回答
  •  悲&欢浪女
    2020-12-24 10:11

    Use it like this in Koltin

    DatePickerDialog(this as Activity, DatePickerDialog.OnDateSetListener { p0, y, m, _ -> func.invoke(y, m + 1) }, c.get(Calendar.YEAR),
            c.get(Calendar.MONTH),
            c.get(Calendar.DAY_OF_MONTH))
            .show()
    

    Use it from anywhere

    tvDateFrom.click {
            showDatePicker(c) { y, m ->
                Utils.debugger("DATE FROM ", " y + $y m $m")
                tvDateFrom.text = "$m-$y".toDate()
            }
        }
    

提交回复
热议问题