Reputation: 31
i want to open a DatePickerDialog from an AppCompatDialog.
private fun pickDate() {
etProduktDatum.setOnClickListener {
getDateTimeCalendar()
DatePickerDialog(this,this,year,month,day).show()
}
}
When i try to create it, android studio complains that there is a Type mismatch on the first parameter of DatePickerDialog:
Type mismatch. Required: Contex Found: EinkaufslisteProduktgekauftDialog
This is my Dialog:
class EinkaufslisteProduktGekauftDialog (context: Context, var produkt : Produkt?, var addDialogListener: AddDialogListener) : AppCompatDialog(context), DatePickerDialog.OnDateSetListener{
var day = 0
var month = 0
var year = 0
var savedday = 0
var savedmonth = 0
var savedyear = 0
Upvotes: 1
Views: 50
Reputation: 355
You can take the context of the activity where ever you are in. You don't want the context of your dialog. Or you call this.getContext (I don't know the kotlin way there).
DatePickerDialog(this.context,this,year,month,day).show()
Upvotes: 1