anv2ie4, 147 PM Brinds |Desenvolvedores Android
Adicionado na API nivel 1
(https:/ideveloper. android. com/quide/topicsmanifestises-sdk-element.htmi#ApiLevels)
Brindar
Kotlin - Brasil | Java (/reference/android/widget/Toast)
open class Toast
Kotlin. Qualquer (https://kotlinlang.org/apillatest/jvmsstdlib/kotlin/-anyfndex.html)
|, android. widget. Brinde (#)
Uma notificagao do sistema é uma exibigdio que contém uma pequena mensagem rapida
para o usuario. A classe do sistema ajuda vocé a criar e mostrar isso. {@more}
Quando a exibigdo é mostrada ao usuario, aparece como uma exibicao flutuante sobre 0
aplicativo. Nunca receberd foco. O usuario provavelmente estard no meio da digitao de
outra coisa. Aideia é ser o mais discreto possivel, ao mesmo tempo em que mostra ao
usuario as informages que vocé deseja que ele veja. Dois exemplos so o controle de
volume e a breve mensagem informando que suas configuragdes foram salvas.
Amaneira mais facil de usar essa classe é chamar um dos métodos estaticos que constréi
tudo o que vocé precisa e retorna um novo objeto Toast.
Observe que as lanchonetes
(https://developer.android.com/reference/com/google/androidimaterialsnackbar/Snackbar) S20
preferidas para mensagens breves enquanto 0 aplicativo esta em primeiro plano.
Observe que as notificagées do sistema que esto sendo enviadas do plano de fundo s8o,
limitadas a taxa, portanto, evite enviar essas notificagdes do sistema em rpida sucessao.
Apartir do Android 12 (API nivel 31), os aplicativos voltados para o Android 12 ou mais
recente terao seus brindes limitados a duas linhas.
Guias do desenvolvedor
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast anaanv2ie4, 147 PM Brinde |Desenvolvedores Android
Para obter informagées sobre como criar notificagées do sistema, leia o guia do desenvolvedor de
Notificacdes do sistema (https:/Adeveloper. android. com/guide/topicstuinotifiers/toasts. htm).
Resumo
Classes aninhadas
abstrair Callback (/reference/kotlinfandroidiwidget/Toast.Callback)
Objeto de retorno de chamada a ser chamado quando a notificagao do
sistema é mostrada ou oculta
Constantes
estatico Int LENGTH_LONG (#LENGTH_LONG:kotln.Int)
(https:/kkotlinlang.orgiapiflatestjvm/stalib/kotlin/-
intindex.htm)) Mostrar 0 modo de exibigo ou notificago de
texto por um longo periodo de tempo.
estatico Int LENGTH_SHORT (#LENGTH_SHORT:kotlin.Int)
(https:/fkotlinlang.orgiapifatestjvmistalibikotlin/-
intindex.html) Mostrar 0 modo de exibigo ou notificagdo de
texto por um curto periodo de tempo.
Construtores publicos
Toast (#Toast(android.content.Context))(context: Context
(https:/ideveloper. android. com/reference/kotlin/android/content/Context.htm))!
Construa um objeto Toast vazio.
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast aneanv2ie4, 147 PM Brinde |Desenvolvedores Android
Public methods
open Unit
(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-unitindex. htm)
open Unit
(https:/kotlinlang.org/apiflatestjvm/stdlib/kotlin/-unitindex. html)
addCallback (#addCallback(and
(callback: Toast.Callback
(ireference/kotlin/androidiwidget
Adds a callback to be notified whe
gancel (#cancel())()
Close the view if it's showing, or d
open Int (https:/ikotlinlang.org/apilatestjvm/stdlib/kotlin/-intindex. html) getDuration (ttgetDuration())()
Return the duration.
open Int (https://kotlinlang.org/apilatest/jvm/stdlibykotlin/-intindex. htm) getGravity (#getGravity))()
open Float
(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-floatfindex. htm!)
‘open Float
{(https:/kotlinlang.org/apifatestivméstalib/kotlin/-floatindex.htmi)
open View
Get the location at which the notit
getHorizontalMargin (#getHor
Return the horizontal margin.
getVerticalMargin (#getVertic:
Return the vertical margin
getView (#getView())()
(https://developer.android.com/reference/kotlin/android/viewView.html)
2
Return the view.
open Int (https:/ikotlinlang.orgapilatestjvmistdlib/kotlin/-intindex. html) getXOf fet (##getXOffset())()
Return the X offset in pixels to ap)
‘open Int (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-intindex.html) get Offset (#getYOffset()) ()
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast
Return the Y offset in pixels to apy
aneanv2ie4, 147 PM Brinde |Desenvolvedores Android
open static Toast (#)!
open static Toast (+)!
open Unit
(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-uniténdex. html)
open Unit
{(https:/kotlinlang.org/apifatestivm/stalibykotlin/-unitindex. html)
open Unit
(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-unitindex. htm)
hitosvideveloperandrols.comireferencolkotivandroidiw igetToast
makeText
(#makeText(android.content.Cor
(context: Context
(https:/ideveloper.android.com/re
1, text: CharSequence
(https:/kotlinlang.org/apillatestiiv
duration: Int
(https:/kotlinlang.orglapilatestiv
Make a standard toast that just c:
makeText (##makeText(android.cc
(context: Context
(https:/ideveloper android. comyre
!, resid: Int
(https://kotliniang.orgfapillatestjv
duration: Int
(https://kotlinlang.org/apivlatestjv
Make a standard toast that just c:
removeCal back (#tremoveCallbz
(callback: Toast.Callback
(reference/kotlin/androidiwidgety
Removes a callback previously ad
addCallback(android.widget.
(#addCallback(android.widget.To
setDuration (#setDuration(kotlir
(https:/fkotlinlang.orgiapillatestjv
Set how long to show the view for.
setGravity (#setGravity(kotlinir
(gravity: Int
(https:/kotlinlang.orglapillatestiiv
xOffset: Int (https://kotliniang.
, yOffset: Int
(htips:/kotlinlang.orglapillatestiv
Set the location at which the notif
aneanv2ie4, 147 PM Brinde |Desenvolvedores Android
open Unit
{(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-unitindex. htm!)
open Unit
{(https:/kotlinlang.org/apiflatestjvm/stdlib/kotlin/-unitindex. htm)
‘open Unit
{(https:/kotlinlang.org/apiflatestjvm/stdlib/kotlin/-unitindex. htm)
open Unit
{(https:/kotlinlang.org/apifiatestivm/stalibykotlin/-unitindex. html)
open Unit
(https:/kotlinlang.org/apiflatest/jvm/stdlib/kotlin/-unitindex. htm)
Constants
AEG Thick ONG
setMargin (#setMargin(kotlin.Flo
(horizontalMargin: Eloat
(https://kotliniang.orgfapilatestjv
verticalMargin: Float
(https://kotliniang.org/apillatestjv
Set the margins of the view.
setText (#setText(kotlin.int)) (re
(https://kotliniang.org/apillatestjv
Update the text in a Toast that we
makeText() methods.
setText (#setText(kotlin.CharSec
(https://kotlinlang.org/apivlatestjv
Update the text in a Toast that we
makeText() methods.
setView (##setView(androidview.
(https:/ideveloper. android. com/re
Set the view to show.
show (#show())(),
‘Show the view for the specified dt
(https:/ideveloper.android.com/quide/topicsimanifestlises-sdk-element.html#tApiLevels)
static val LENGTH_LONG: Int (https:/kotlinlang.org/api/latestjvmistdlib/kotli/-intfindex.html)
hitossldoveloperandrols.comreferencolkotivandroidiw igetToast
eneBrinde |Desenvolvedores Android
‘Show the view or text notification for a long period of time. This time could be user-
definable.
Value: 1
See Also
#setDuration (##setDuration(kotlin.Int))
AdaNUG ThicSHORT
(https:/ideveloper. android. com/quide/topicsmanifestiuses-sdk-element.html#ApiLevels)
static val LENGTH_SHORT: Int (https:/kotliniang.org/apillatestivm/stdlib/kotlin/-intindex.html)
‘Show the view or text notification for a short period of time. This time could be user-
definable. This is the default.
Value: @
See Also
#setDuration (#setDuration(kotlin.int))
Public constructors
TRASH apiievels
(httos://develover.android.com/auide/topicsimanifesthses-sdk-element.htmi##AbiLevels)
hitosvideveloperandrols.comireferencolkotivandroidiw igetToast eneanv2ie4, 147 PM Brinde |Desenvolvedores Android
Toast(context: Context (https:/ideveloper.android.com/reference/kotlin/androidicontent/Context.html
Construct an empty Toast object. You must call before you can call .setView
(i#setView(android.view.View)) show (#show())
Parameters
context Context
(https://developer.android.com/reference/kotlin/android/content/Contex
!: The context to use. Usually your object.android.app.Activity
(https:/ideveloper.android.com/reference/kotlin/android/appiActivity.htm.
Public methods
addGalibacko
(https:/ideveloper. android. com/guide/topics*manifesttses-sdk-element.htmi#ApiLevels)
open fun addCallback(callback: Toast.Callback (/reference/kotlin/androidiwidget/Toast.Callback
Adds a callback to be notified when the toast is shown or hidden. Note that if the toast is
blocked for some reason you won't get a call back.
Parameters
callback ‘Toast.Callback (/reference/kotlin/androidwidget/Toast.Callback): This
value cannot be .nul1.
hitosvldeveloperandrols.comireferencolkotivandroidiw igetToast maanv2ie4, 147 PM Brinde |Desenvolvedores Android
See Also
#removeCal Iback (Callback) (#removeCallback(android. widget Toast.Callback))
aCe}?! level 1
{(https:/ideveloper.android, comguide/topicsimanifestlises-sdk-element.htmlifApiLevels)
open fun cancel(): Unit (https:/kotlinlang.orgiapi/latestjvmistdlib/kotlin/-unitfndex.htm!)
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.
getDumatian
(https:/ideveloper. android. com/guide/topics#manifesttuses-sdk-element.html#ApiLevels)
open fun getDuration(): Int (https://kotlinlang.org/apiflatest/ivm/stdlib/kotlin/-intindex.htm))
Return the duration.
Return
Int Value is , or andr jet. Toast#LENGTH_SHORT
(https:/hkotlinlang.orgiapiflatestvm/stdlibikotlin/-(#LENGTH_SHORT:kotlin.Int)
intindex. html) android.widget.Toast#LENGTH_LONG
(#LENGTH_LONG:kotlin.int)
See Also
#setDuration (##setDuration(kotlin.int))
hitosvldeveloperandrols.comireferencolkotivandroidiw igetToast aneBrinde |Desenvolvedores Android
getGravity
(https:/ideveloper. android.com/guide/topics#manifestluses-sdk-element.htmi#ApiLevels)
open fun getGravity(): Int (https:/kotlinlang.orgapillatestivm/stdlib/kotlin/-intindex. html)
Get the location at which the notification should appear on the screen.
Warning: Starting from Android , for apps targeting AP! level or higher, this method
shouldn't be called on text toasts as its return value may not reflect actual value since text
toasts are not rendered by the app anymore. Build. VERSION CODES#R
(https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
Build. VERSION CODES#R
(https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
See Also
android. view. Gravity (https:/developer. android. com/reference/kotlin/androidiview/Gravity.html)
#getGravity (#getGravity())
gattorizoatalMargin
(https:/ideveloper. android. com/guide/topicsmanifesttuses-sdk-element.html#tApiLevels)
open fun getHorizontalMargin(): Float (https://kotlinlang.org/api/latestvmistdlib/kotlin/-floatindey
Return the horizontal margin.
Warning: Starting from Android , for apps targeting API level or higher, this method
shouldn't be called on text toasts as its return value may not reflect actual value since text
toasts are not rendered by the app anymore. Build. VERSTON_CODES#R
{(https:/ideveloper. android. com/reference/kotlin/android/os/Build, VERSION_CODES.html#R:kotlin.Int)
Build. VERSION_CODES#R
{(https:/ideveloper. android. com/reference/kotlin/androidios/Build, VERSION_CODES.html#R:kotlin.Int)
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast eneanv2ie4, 147 PM Brinde |Desenvolvedores Android
getVextioalMargin
(https:/ideveloper.android.com/guide/topics/manifestluses-sdk-element.htmi#tApiLevels)
open fun getVerticalMargin(): Float (https:/kotlinlang.org/api/latestjvm/stdlib/kotlin/-float/index.h
Return the vertical margin.
Warning: Starting from Android , for apps targeting API level or higher, this method
shouldn't be called on text toasts as its return value may not reflect actual value since text
toasts are not rendered by the app anymore. Build. VERSION_CODES#R
{(https:/ideveloper. android. com/reference/kotlin/androidios/Build, VERSION_CODES.html#R:kotlin.Int)
Build. VERSION CODES#R
{(https:/ideveloper. android. com/reference/kotlin/androidios/Build, VERSION_CODES.html#R:kotlin.Int)
gatViewlevel 1
(https://developer.android.com/guide/topics/manifestluses-sdk-element.html#ApiLevels)
Deprecated in AP! level 30
(https://deve loper.android.com/guide/topics/manifestluses-sdk-element.html#ApiLevels)
open fun get¥tew(): View (https:/developer.android.com/reference/kotlin/android/viewView.html)?
Deprecated: Custom toast views are deprecated. Apps can create a standard text toast with the
makeText (android
(#makeText(endroid. content. Context, %20kotlin, CharSequence, %20kotlin.Int)) method, or use a
‘Snackbar (https:/ideveloper.android. com/reference/com/google/android/materialisnackbar/Snackbar)
when in the foreground. Starting from Android Build. VERSION_CODES#R
{(https:/ideveloper.android.com/reference/kotlin/android/os/Build VERSION_CODES. html#R:kotlin.Int),
apps targeting API level Build. VERSTON_CODES#R
(https:fideveloper. android. com/reference/kotlin/androidios/Build. VERSION_CODES.html#R:kotlin.Int) or
higher that are in the background will not have custom toast views displayed.
ontent. Context, java. lang. CharSequence, int)
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast soneBrinde |Desenvolvedores Android
Return the view.
Toasts constructed with that haven't called with a non- view will return here.
Toast (android. content ..Context) (#Toast(android.content.Context))
setView(android. view. View) (#setView(android.view.View)) nulLnulL
Starting from Android , in apps targeting AP! level or higher, toasts constructed with or its
variants will also return here unless they had called with a non- view. If you want to be
notified when the toast is shown or hidden, use .Build.VERSTON_CODES#R
{(https:/ideveloper.android, com/reference/kotlin/androidios/Build VERSION_CODES.html#R:kotlin.Int)
android.os.Build. VERSION CODES#R
{(https:/ideveloper. android. com/reference/kotlin/androidios/Build, VERSION_CODES.html#Rkotlin.Int)
makeText content .Context,, java. Jang. CharSequence,, int),
(#makeText(android.content. Context, %20kotlin.CharSequence,%20kotiin.Int))
null setView(android. view. View) (#setView(androidview.View))
null addCallback (android widget Toast Callback)
(#raddCallback(android.widget Toast.Callback))
ndr
See Also
fsetView (#tsetView(androidview.View))
getXOffset:
{(https:/ideveloper. android. com/quide/topicsmanifestuses-sdk-element.htmi#ApiLevels)
open fun getxoffset(): Int (https://kotlinlang.orgfapi/latest/vm/stdlib/kotlin/-intindex.htm))
Return the X offset in pixels to apply to the gravity's location.
Warning: Starting from Android , for apps targeting AP! level or higher, this method
shouldn't be called on text toasts as its return value may not reflect actual value since text
toasts are not rendered by the app anymore. Build. VERSION CODES#R
(https:/ideveloper.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
Build. VERSION _CODES#R
(https:/ideveloper.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
hitosvldeveloperandrols.comireferencolkotivandroidiw igetToast wieanv2ie4, 147 PM Brinde |Desenvolvedores Android
getYOfiset:
(https:/ideveloper. android.com/guide/topics#manifesttuses-sdk-element.htmi#ApiLevels)
open fun getYOffset(): Int (https:/kotlinlang.orgiapillatestivm/stdlib/kotlin/-intindex. html)
Return the Y offset in pixels to apply to the gravity's location.
Warning: Starting from Android , for apps targeting AP! level or higher, this method
shouldn't be called on text toasts as its return value may not reflect actual value since text
toasts are not rendered by the app anymore. VERSION_CODES#R
(https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
Build. VERSION CODES#R
(https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#R:kotlin.Int)
maak Fenda 1
(https:/ideveloper. android. com/guide/topicsmanifesttuses-sdk-element.html#ApiLevels)
open static fun makeText (
context: Context (https:/developer. android. com/reference/kotlin/android/contenContexthtml)
text: CharSequence (https://kotlinlang.org/api/latest/ivm/stdlib/kotlin/-char-sequence/ndex. htm)!
duration: Int (https:/kotlinlang.orgapi/latestvm/stdlib/kotlin/-intindex.html)
): Toast (#)
Make a standard toast that just contains text.
Parameters
context Context
(https:/ideveloper.android. com/reference/kotlin/androidicontent/Contex
: The context to use. Usually your object.androis Activity
(https:/ideveloper. android. com/reference/kotlin/android/app/Activity. htm
hitosvldeveloperandrols.comireferencolkotivandroidiw igetToast saneanv2ie4, 147 PM Brinde |Desenvolvedores Android
text CharSequence
(https://kotlinlang.org/apiflatestiivmsstdlib/kotlin/-char-sequence/ndex.h
The text to show. Can be formatted text.
duration Int (https://kotlinlang.org/apilatest/ivm/stdlibikotlin/-intindex.htm)): How
to display the message. Either or Value is , or LENGTH_SHORT
(#LENGTH_SHORT:Kotlin.Int)LENGTH_LONG (#LENGTH_LONG:kotlin.Int)
android. widget. Toast#LENGTH_SHORT (#LENGTH_SHORT:kotlin.Int)
android.widget.. Toast#tLENGTH_LONG (#LENGTH_LONG:kotlin.int)
maake Tevdiel 1
(https:/ideveloper. android. com/guide/topics*manifesttuses-sdk-element.html#ApiLevels)
open static fun makeText(
context: Context (https:/developer. android. com/reference/kotlinfandroid/contenContexthtml) !
resId: Int (https:/kotlinlang.org/api/latestvm/stalib/kotlin/-inténdex.html)
duration: Int (https:/kotlinlang.org/api/latestvm/stdlib/kotli/-intindex.html)
): Toast (#)!
Make a standard toast that just contains text from a resource.
Parameters
context, Context
{(https://developer.android, com/reference/kotlin/androidicontent/Contex
{: The context to use. Usually your object android. app. Activity
(https:/ideveloper.android. com/reference/kotlin/android/app/Activity.htm
resid Int (https://kotlinlang.org/apiflatest/ivmstdlib/kotlin/-intindex.htm)): The
resource id of the string resource to use. Can be formatted text
duration nt (https://kotlinlang.org/apilatestivm/stdlibikotlin/-intindex.htm)): How
to display the message. Either or Value is , or LENGTH_SHORT
hitossldoveloperandrols.comreferencolkotivandroidiw igetToast s3H9Brinde |Desenvolvedores Android
(#LENGTH_SHORT:kotlin.Int)LENGTH_LONG (#LENGTH_LONG:kotlin.Int)
android. widget. Toast#LENGTH_SHORT (#LENGTH_SHORT:kotlin.Int)
android.widget. Toast#LENGTH_LONG (#LENGTH_LONG:kotlin.int)
Exceptions
android. content. res. Resources .NotFoundException if the resource can't be found.
removeGalliback
{(https:/ideveloper. android. com/quide/topicsmanifesttses-sdk-element.htmi#ApiLevels)
open fun removeCallback (callback: Toast.Callback (/reference/kotlin/android/widget/Toast. Call
Removes a callback previously added with .addCallback(android widget . Toast Callback),
(#addCallback(android.widget.Toast.Callback))
Parameters
callback Toast.Callback (/reference/kotlin/android/widget/Toast.Callback): This
value cannot be .nu11
setDuKation
(https:/ideveloper.android.com/quide/topicsimanifestlises-sdk-element.html##ApiLevels)
open fun setDuration(duration: Int (https://kotiinlang.orgiapi/latestjvm/stdlib/kotlin/-int/index. html
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast saneBrinde |Desenvolvedores Android
Set how long to show the view for.
Parameters
duration Int (https:/hkotlinlang.orgapillatestivmsstdlib/kotlin/-intindex.htm)}
Value is , or android.widget.Toast#LENGTH SHORT
(#LENGTH_SHORT:kotlin.Int)android. widget. Toast#LENGTH_LONG
(#LENGTH_LONG:kotlin.int)
See Also
#LENGTH_ SHORT (#LENGTH_SHORT:kotlin.int)
#LENGTH_LONG (#LENGTH_LONG:kotlin.int)
setGrawvityt
{(https:/ideveloper. android. com/quide/topics*manifestuses-sdk-element.html#ApiLevels)
open fun setGravity(
gravity: Int (https:/kotlinlang.org/api/iatest/ivm/stdlib/kotlin/-intfndex.html)
xOffset: Int (https://kotlinlang.org/api/latest/ivm/stdlib/kotlin/-intindex. htm),
yOffset: Int (https:/kotlinlang.org/api/latest/ivm/stalib/kotlin/-intindex.htm))
): Unit (https://kotlinlang.org/apilatest/jvm/stdlib/kotlin/-unitindex.html)
Set the location at which the notification should appear on the screen.
Warning: Starting from Android , for apps targeting API level or higher, this method is a no-
‘op when called on text toasts. Build. VERSION. CODES#R
(https:/Adeveloper.android, com/reference/kotinfandroid/os/Build VERSION. CODES.htmi#R:kotlin Int)
Build. VERSION CODES#R
(https:/Ideveloper.android, com/reference/kotinfandroid/os/Build VERSION_CODES.html##Rekotlin Int)
See Also
android. view.Gravity (https:/developer. android. com/reference/kotlinfandroidiview'Gravity.html)
hitosvldeveloperandrols.comireferencolkotivandroidiw igetToast ssoanv2ie4, 147 PM Brinde |Desenvolvedores Android
figetGravity (#getGravity())
nel 1
{(https:/Aleveloper.android, com/quide/topicsimanifestisses-sdk-element.htmli#ApiLevels)
open fun setMargin(
horizontalNargin: Float (hitps://kotlinlang.org/apiltatest/jvmstalib/kotlin/-floatfindex.html)
verticalMargin: Float (https:/kotlinlang.org/apilatestjvm/stdlib/kotlin/-floatindex.htm))
): Unit (https:/kotlinlang.org/apilatestjvm/stdlib/kotlin/-unitindex.htm))
Set the margins of the view.
Warning: Starting from Android , for apps targeting API level or higher, this method is a no-
op when called on text toasts. Build. VERSION CODES#R
{(https:/ideveloper. android. com/reference/kotlin/androidios/Build, VERSION_CODES.html#R:kotlin.Int)
Build. VERSION CODES#R
{(https:/ideveloper. android. com/reference/kotlin/android/os/Build, VERSION_CODES.html#R:kotlin.Int)
Parameters
horizontalMargin Float (https://kotlinlang.org/apiflatestvm/stdlib/kotlin/-floatindex.htm)):
The horizontal margin, in percentage of the container width, between
the container's edges and the notification
verticalMargin Float (https://kotlinlang.org/apiflatest/jvméstdlib/kotlin/-floatindex.html):
The vertical margin, in percentage of the container height, between
the container's edges and the notification
se@tTexbllevel 1
(https:/ideveloper. android. com/guide/topics#manifesttuses-sdk-element.htmi#ApiLevels)
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast renoanv2ie4, 147 PM Brinde |Desenvolvedores Android
open fun setText(resId: Int (https://kotlinlang.org/apilatest/ivm/stdlib/kotlin/-intindex.htm)) : Unit
Update the text in a Toast that was previously created using one of the makeText()
methods.
Parameters
resId nt (https://kotlinlang.org/apifatestivméstdlib/kotlin/-intindex.htm)): The
new text for the Toast.
set Text. level 1
(https://developer.android.com/guide/topicsimanifestiises-sdk-element.html#ApiLevels)
open fun setText(s: CharSequence (https://kotlinlang.orgiapillatestjvm/stdlib/kotlin/-char-sequence/
Update the text in a Toast that was previously created using one of the makeText()
methods.
Parameters
s CharSequence
(https:/kotlinlang.org/apifatestiivmistalib/kotlin/-char-
sequencefindex.html)
{: The new text for the Toast.
setViewlevel1
{(https:/ideveloper. android. com/quide/topicsmanifestuses-sdk-element.html#ApiLevels)
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast ameanv2ie4, 147 PM Brinde |Desenvolvedores Android
Deprecated in APLevel 30
{(https:/ideveloper. android.com/quide/topicsmanifesttses-sdk-element.htmi#ApiLevels)
open fun setiiew(view: View (https:/ideveloper.android. com/reference/kotlin/android/view/View.html)
Deprecated: Custom toast views are deprecated. Apps can create a standard text toast with the
makeText (android. content. Context, java. lang. CharSequence, int)
(#makeText(android. content. Context, %20kotlin. CharSequence, %20kotlin.Int)) method, or use a
‘Snackbar (https:/ideveloper.android. com/reference/com/google/android/materialisnackbar/Snackbar)
when in the foreground. Starting from Android Build. VERSION_CODES#R
(https:fideveloper. android. com/reference/kotlin/android/os/Build. VERSION_CODES. html#R:kotlin.Int),
apps targeting API level Build. VERSTON_CODES#R
(https:fideveloper. android. com/reference/kotlin/androidios/Build.VERSION_CODES.html#R:kotlin.Int) or
higher that are in the background will not have custom toast views displayed.
Set the view to show.
See Also
digetView (##getView())
shew APL evel 1
(https:/ideveloper. android. com/guide/topicsmanifesttuses-sdk-element.htmi#ApiLevels)
open fun show(): Unit (https:/fkotlinlang.org/apifatest/vm/stdlib/kotlin/-unitindex htm)
‘Show the view for the specified duration.
Note that toasts being sent from the background are rate limited, so avoid sending such
toasts in quick succession.
hitosvldoveloperandrols.comireferencolkothvandroidiw igetToast seeanvarza, 147 PM Brinde |Desenvolvedores Android
Content anc code samples on this page are subject to the licenses described in the Content License (ficense).
Java and OpenDk are trademarks or registered trademarks of Oracle andi its affiliates.
Last updated 2024-04-04 UTC.
sone
ntps:idevelopor androkd.comreferencelkotiniandroiiv lige Toast