Issue
I've created an extension of DialogFragment()
:
class AlertDialogFragment(context: Context,
val positiveButtonText: String,
val positiveButtonListener: DialogInterface.OnClickListener,
val negativeButtonText: String,
val negativeButtonListener: DialogInterface.OnClickListener,
neutralButtonText: String,
neutralButtonListener: DialogInterface.OnClickListener
) : DialogFragment() {
however I want the last 2 parameters to be optional.
How can I achieve this?
I can't set neutralButtonListener: DialogInterface.OnClickListener = null
because DialogInterface.OnClickListener
is a non null type.
Solution
Check this out
class AlertDialogFragment(context: Context, val positiveButtonText: String, val positiveButtonListener: DialogInterface.OnClickListener,
val negativeButtonText: String, val negativeButtonListener: DialogInterface.OnClickListener, neutralButtonText: String = "", neutralButtonListener: DialogInterface.OnClickListener?=null) : DialogFragment() { }
Answered By - Lokesh Desai
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.