java.lang.Object | |
↳ | android.widget.Toast |
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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | LENGTH_LONG | Show the view or text notification for a long period of time. | |||||||||
int | LENGTH_SHORT | Show the view or text notification for a short period of time. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct an empty Toast object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Close the view if it's showing, or don't show it if it isn't showing yet.
| |||||||||||
Return the duration.
| |||||||||||
Get the location at which the notification should appear on the screen.
| |||||||||||
Return the horizontal margin.
| |||||||||||
Return the vertical margin.
| |||||||||||
Return the view.
| |||||||||||
Return the X offset in pixels to apply to the gravity's location.
| |||||||||||
Return the Y offset in pixels to apply to the gravity's location.
| |||||||||||
Make a standard toast that just contains a text view with the text from a resource.
| |||||||||||
Make a standard toast that just contains a text view.
| |||||||||||
Set how long to show the view for.
| |||||||||||
Set the location at which the notification should appear on the screen.
| |||||||||||
Set the margins of the view.
| |||||||||||
Update the text in a Toast that was previously created using one of the makeText() methods.
| |||||||||||
Update the text in a Toast that was previously created using one of the makeText() methods.
| |||||||||||
Set the view to show.
| |||||||||||
Show the view for the specified duration.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Show the view or text notification for a long period of time. This time could be user-definable.
Show the view or text notification for a short period of time. This time could be user-definable. This is the default.
Construct an empty Toast object. You must call setView(View) before you can call show().
context | The context to use. Usually your Application or Activity object. |
---|
Close the view if it's showing, or don't show it if it isn't showing yet. You do not normally have to call this. Normally view will disappear on its own after the appropriate duration.
Return the duration.
Get the location at which the notification should appear on the screen.
Return the horizontal margin.
Return the vertical margin.
Return the view.
Return the X offset in pixels to apply to the gravity's location.
Return the Y offset in pixels to apply to the gravity's location.
Make a standard toast that just contains a text view with the text from a resource.
context | The context to use. Usually your Application or Activity object. |
---|---|
resId | The resource id of the string resource to use. Can be formatted text. |
duration | How long to display the message. Either LENGTH_SHORT or LENGTH_LONG |
if the resource can't be found. | |
Resources.NotFoundException |
Make a standard toast that just contains a text view.
context | The context to use. Usually your Application or Activity object. |
---|---|
text | The text to show. Can be formatted text. |
duration | How long to display the message. Either LENGTH_SHORT or LENGTH_LONG |
Set how long to show the view for.
Set the location at which the notification should appear on the screen.
Set the margins of the view.
horizontalMargin | The horizontal margin, in percentage of the container width, between the container's edges and the notification |
---|---|
verticalMargin | The vertical margin, in percentage of the container height, between the container's edges and the notification |
Update the text in a Toast that was previously created using one of the makeText() methods.
resId | The new text for the Toast. |
---|
Update the text in a Toast that was previously created using one of the makeText() methods.
s | The new text for the Toast. |
---|
Show the view for the specified duration.