Android Guides | Samples

Android.Widget.Toast Class

A toast is a view containing a quick little message for the user.

See Also: Toast

Syntax

[Android.Runtime.Register("android/widget/Toast", DoNotGenerateAcw=true)]
public class Toast : Object

Remarks

A toast is a view containing a quick little message for the user. The toast class helps you create and show those.

When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved.

The easiest way to use this class is to call one of the static methods that constructs everything you need and returns a new Toast object.

Developer Guides

For information about creating Toast notifications, read the Toast Notifications developer guide.

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Widget.Toast are listed below.

See Also: Object

Public Constructors

Construct an empty Toast object.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

DurationToastLength. Return the duration.
[read-only]
GravityGravityFlags. Get the location at which the notification should appear on the screen.
[read-only]
HorizontalMarginSingle. Return the horizontal margin.
[read-only]
VerticalMarginSingle. Return the vertical margin.
ViewView. Return the view.
[read-only]
XOffsetInt32. Return the X offset in pixels to apply to the gravity's location.
[read-only]
YOffsetInt32. Return the Y offset in pixels to apply to the gravity's location.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

Cancel()
Close the view if it's showing, or don't show it if it isn't showing yet.
static
MakeText(Context, ICharSequence, ToastLength) : Toast
Make a standard toast that just contains a text view.
static
MakeText(Context, Int32, ToastLength) : Toast
Make a standard toast that just contains a text view with the text from a resource.
static
MakeText(Context, String, ToastLength) : Toast
SetGravity(GravityFlags, Int32, Int32)
Set the location at which the notification should appear on the screen.
SetMargin(Single, Single)
Set the margins of the view.
SetText(ICharSequence)
Update the text in a Toast that was previously created using one of the makeText() methods.
SetText(Int32)
Update the text in a Toast that was previously created using one of the makeText() methods.
SetText(String)
Show()
Show the view for the specified duration.