Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DatePickerFragment : DialogFragment(), DatePickerDialog.OnDateSetListener {
- override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
- // Use the current date as the default date in the picker
- val c = Calendar.getInstance()
- val year = c.get(Calendar.YEAR)
- val month = c.get(Calendar.MONTH)
- val day = c.get(Calendar.DAY_OF_MONTH)
- // Create a new instance of DatePickerDialog and return it
- return DatePickerDialog(activity!!, this, year, month, day)
- }
- override fun onDateSet(view: DatePicker, year: Int, month: Int, day: Int) {
- // Do something with the date chosen by the user
- val date_picked = "".plus(day).plus("/").plus(month).plus("/").plus(year)
- (activity as MyActivity).updateDate(date_picked)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement