Click the Android button to show another Toast message, depending on the number of clicks

I want a button that can display another message for a toast, depending on the time the user clicks. The code I'm writing is as shown below. However, after I click, all four toasts will appear. Can someone help me fix this? thank!

GetVS.Click += delegate {

            if(count==0)
            {
                Toast.MakeText (this, "Beep Boop0", ToastLength.Short).Show ();
            }
            if(count==1)
            {
                Toast.MakeText (this, "Beep Boop1", ToastLength.Short).Show ();
            }
            if(count==2)
            {
                Toast.MakeText (this, "Beep Boop2", ToastLength.Short).Show ();
            }
            else
            {
                Toast.MakeText (this, "Beep Boop else", ToastLength.Short).Show ();
            }

                count++;
        };
+4
source share
1 answer

Toast.MakeTextreturns a new Toast instance, you can create it outside the delegate, and then call myToast.setTextto change the text, and then call Showto display it.

You create an instance of class 4 with Toast.MakeTextand do not change the text.

+1

All Articles