fun Fragment.showSnackbar(message: CharSequence?, duration: Int = SNACKBAR_DEFAULT_DURATION, block: Snackbar.() -> Unit = {}): Unit
Creates a new Snackbar with specified message and duration, then calls optional block with Snackbar as receiver before displaying.
Uses Fragment.getView as the parent view. Duration defaults to SNACKBAR_DEFAULT_DURATION.
Does nothing if the fragment isn't attached to an activity, or if message is null.
Example:
showSnackbar("Do you agree?") {
setAction("yes") { validateAndSubmit(true) }
}
fun Fragment.showSnackbar(@StringRes messageResId: Int, duration: Int = SNACKBAR_DEFAULT_DURATION, block: Snackbar.() -> Unit = {}): Unit
Creates a new Snackbar with specified message and duration, then calls optional block with Snackbar as receiver before displaying.
Uses Fragment.getView as the parent view. Duration defaults to SNACKBAR_DEFAULT_DURATION.
Does nothing if the fragment isn't attached to an activity.
Example:
showSnackbar(R.string.do_you_agree) {
setAction(R.string.yes) { validateAndSubmit(true) }
}