How can I add a callback to a snackbar in c#? I found the way to do it but in java How can I be notified when a Snackbar has dismissed itself?
I tried to do the same in c#
snackBar.AddCallback(new Snackbar.Callback
{
});
I did find out that exists in snackbar callback class, but unfortunately I didn't find any info in xamarin docs about it.
[Register("onDismissed", "(Landroid/support/design/widget/Snackbar;I)V", "GetOnDismissed_Landroid_support_design_widget_Snackbar_IHandler")]
public virtual void OnDismissed(Snackbar transientBottomBar, int e);
You could define a CallBack
first,then use AddCallBack
method.
class MySnackCallBack : BaseTransientBottomBar.BaseCallback
{
public override void OnDismissed(Java.Lang.Object transientBottomBar, int e)
{
base.OnDismissed(transientBottomBar, e);
}
public override void OnShown(Java.Lang.Object transientBottomBar)
{
base.OnShown(transientBottomBar);
}
}
Snackbar snackbar = Snackbar.Make(view, message, Snackbar.LengthShort);
snackbar.AddCallback(new MySnackCallBack());
snackbar.Show();