Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

toast that wait for an exist toast to disapear

$
0
0

Hi,

My problem is that I created a toast that works fine, but unfortunately, toasts are not very polite, and don't not wait until the current shown toast will
finish its job. It just moves it away.
I can solve it in an ugly way, which means to put Task.Delay() before the second toast (in order to let the first toast to finish its job).

I wondered if there is a better way.

This is how I created the toast.
1. I created an interface in Xamarin Forms:
public interface IMessage
{
void LongAlert(string message);
void ShortAlert(string message);
}

  1. In Android Project I wrote the implementation:

    public class MessageAndroid : IMessage
    {
    public void LongAlert(string message)
    {
    Toast.MakeText(Application.Context,message, ToastLength.Long).Show();
    }

        public void ShortAlert(string message)
        {
            Toast.MakeText(Application.Context, message, ToastLength.Short).Show();
        }
    

    }


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>