I am still a relative newbie at Kotlin and, after a fair bit of digging, cant fix what looks to be a simple problem. For the code below the compiler returns: The feature "unit conversion" is disabled for "function = positiveButtonClick" and function = negativeButtonClick"
Why? What do I need to do?
Thanks
called with MessageBox(context, "Hello Test", "My Message");
fun MessageBox(contxt: Context?, title: String, message: String): Boolean {
val builder = AlertDialog.Builder(contxt)
with(builder) {
setTitle(title)
setMessage(message)
setPositiveButton("YES", DialogInterface.OnClickListener(function = positiveButtonClick))
setNegativeButton("NO", DialogInterface.OnClickListener(function = negativeButtonClick))
show()
}
return false
}
val positiveButtonClick = { dialog: DialogInterface, which: Int -> Unit
Log.i("Dialog", "Yes")
}
val negativeButtonClick = { dialog: DialogInterface, which: Int -> Unit
Log.i("Dialog", "No")
}