First, instantiate a Toast object with one of the MakeText()
methods. This method takes three parameters: the application Context
, the text message, and the duration for the toast. It returns a properly initialized Toast object. You can display the toast notification with Show()
, as shown in the following example:
Context context = Application.Context;
string text = "Hello toast!";
ToastLength duration = ToastLength.Short;
var toast = Toast.MakeText(context, text, duration);
toast.Show();
This example demonstrates everything you need for most toast notifications. You should rarely need anything else. You may, however, want to position the toast differently or even use your own layout instead of a simple text message. The following sections describe how you can do these things.
You can also chain your methods, call as a one-liner and avoid holding on to the Toast object, like this:
Toast.MakeText(Application.Context, "Hello toast!", ToastLength.Short).Show();
For more information refer to the more complete Android documentation on the topic.