A Toast provides simple feedback about an operation in a small popup and automatically disappears after a timeout. It only fills the amount of space required for the message and the current activity remains visible and interactive.
Parameter | Details |
---|---|
context | The context to display your Toast in. this is commonly used in an Activity and getActivity() is commonly used in a Fragment |
text | A CharSequence that specifies what text will be shown in the Toast. Any object that implements CharSequence can be used, including a String |
resId | A resource ID that can be used to provide a resource String to display in the Toast |
duration | Integer flag representing how long the Toast will show. Options are Toast.LENGTH_SHORT and Toast.LENGTH_LONG |
gravity | Integer specifying the position, or "gravity" of the Toast. See options here |
xOffset | Specifies the horizontal offset for the Toast position |
yOffset | Specifies the vertical offset for the Toast position |
A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive.
A more recent alternative to Toast is SnackBar. SnackBar offers an updated visual style and allows the user to dismiss the message or take further action. See the SnackBar documentation for details.
https://developer.android.com/reference/android/widget/Toast.html