Class ToastCompat
java.lang.Object
android.widget.Toast
com.pranavpandey.android.dynamic.toasts.internal.ToastCompat
A Toast to fix the bad token exception on API 25.
-
Nested Class Summary
Nested classes/interfaces inherited from class android.widget.Toast
Toast.Callback -
Field Summary
Fields inherited from class android.widget.Toast
LENGTH_LONG, LENGTH_SHORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintfloatgetToast()floatgetView()intintstatic ToastMake a standard toast that just contains a text view.static ToastCompatmakeText(Context context, CharSequence text, int duration) Make a standard toast that just contains a text view.voidsetDuration(int duration) voidsetGravity(int gravity, int xOffset, int yOffset) voidsetMargin(float horizontalMargin, float verticalMargin) voidsetText(int resId) voidvoidvoidshow()Methods inherited from class android.widget.Toast
addCallback, cancel, removeCallback
-
Constructor Details
-
ToastCompat
-
-
Method Details
-
makeText
public static ToastCompat makeText(@NonNull Context context, @Nullable CharSequence text, int duration) Make a standard toast that just contains a text view.- Parameters:
context- The context to use.text- The text to show. Can be formatted text.duration- The duration for the toast, eitherToast.LENGTH_SHORTorToast.LENGTH_LONG.- Returns:
- The standard toast that just contains a text view.
-
makeText
public static Toast makeText(@NonNull Context context, @StringRes int resId, int duration) throws Resources.NotFoundException Make a standard toast that just contains a text view.- Parameters:
context- The context to use.resId- The resource id of the string resource to use. Can be formatted text.duration- The duration for the toast, eitherToast.LENGTH_SHORTorToast.LENGTH_LONG.- Returns:
- The standard toast that just contains a text view.
- Throws:
Resources.NotFoundException
-
show
public void show() -
setDuration
public void setDuration(int duration) - Overrides:
setDurationin classToast
-
setGravity
public void setGravity(int gravity, int xOffset, int yOffset) - Overrides:
setGravityin classToast
-
setMargin
public void setMargin(float horizontalMargin, float verticalMargin) -
setText
public void setText(int resId) -
setText
-
setView
-
getHorizontalMargin
public float getHorizontalMargin()- Overrides:
getHorizontalMarginin classToast
-
getVerticalMargin
public float getVerticalMargin()- Overrides:
getVerticalMarginin classToast
-
getDuration
public int getDuration()- Overrides:
getDurationin classToast
-
getGravity
public int getGravity()- Overrides:
getGravityin classToast
-
getXOffset
public int getXOffset()- Overrides:
getXOffsetin classToast
-
getYOffset
public int getYOffset()- Overrides:
getYOffsetin classToast
-
getView
-
getToast
-