Closed JKhanh closed 4 years ago
Use this way
datePicker.setOnDateSelectedListener{ year, month, day, index -> var strDay = day.toString() var strMonth = (month+1).toString() if (strMonth.toInt()<10) strMonth = "0$strMonth" if (day<10) strDay = "0$day" textView.text = strDay+"-"+strMonth+"-"+year.toString() popupWindow.dismiss() }
When I call setOnDateSelectedListener I get an error "Expresstion cannot be invoke as a function. The function
invoke()
is not found" My code: datePicker.onDateSelectedListener(object: DatePickerTimeline.OnDateSelectedListener{ override fun onDateSelected(year: Int, month: Int, day: Int, index: Int) { calendar.set(year, month, day) viewModel.getDiaryByPriority(calendar, "objective") } })