我想使用此库https://github.com/wdullaer/MaterialDateTimePicker显示日期选择器对话框
implementation "com.wdullaer:materialdatetimepicker:3.6.4"
这是我的代码在我的片段中
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
val now = Calendar.getInstance()
val currentYear: Int = now.get(Calendar.YEAR)
val currentMonth: Int = now.get(Calendar.MONTH)
val currentDay: Int = now.get(Calendar.DAY_OF_MONTH)
val datePickerDialog = DatePickerDialog.newInstance(DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
// do something here
}, currentYear, currentMonth, currentDay)
datePickerDialog.setTitle("INI JUDUL")
datePickerDialog.setAccentColor(resources.getColor(R.color.colorPrimary))
datePickerDialog.setOkText("SIP")
datePickerDialog.setCancelText("GA JADI")
datePickerDialog.show(fragmentManager,"")
但是当我想在此行datePickerDialog.show(fragmentManager,"")
中显示该日期选择器对话框时出现错误,就像这样
我相信我提供了正确的论点,但仍然..它给出了一个错误
val now = Calendar.getInstance()
val currentYear: Int = now.get(Calendar.YEAR)
val currentMonth: Int = now.get(Calendar.MONTH)
val currentDay: Int = now.get(Calendar.DAY_OF_MONTH)
val datePickerDialog = DatePickerDialog.newInstance(DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth ->
// do something here
}, currentYear, currentMonth, currentDay)
datePickerDialog.setTitle("INI JUDUL")
datePickerDialog.setAccentColor(resources.getColor(R.color.colorPrimary))
datePickerDialog.setOkText("SIP")
datePickerDialog.setCancelText("GA JADI")
datePickerDialog.show(activity!!.fragmentManager, "Datepickerdialog");
希望它能起作用!