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
-
Method Summary
Modifier and TypeMethodDescriptionint
int
float
getToast()
float
getView()
int
int
static Toast
Make a standard toast that just contains a text view.static ToastCompat
makeText
(Context context, CharSequence text, int duration) Make a standard toast that just contains a text view.void
setDuration
(int duration) void
setGravity
(int gravity, int xOffset, int yOffset) void
setMargin
(float horizontalMargin, float verticalMargin) void
setText
(int resId) void
void
void
show()
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_SHORT
orToast.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_SHORT
orToast.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:
setDuration
in classToast
-
setGravity
public void setGravity(int gravity, int xOffset, int yOffset) - Overrides:
setGravity
in classToast
-
setMargin
public void setMargin(float horizontalMargin, float verticalMargin) -
setText
public void setText(int resId) -
setText
-
setView
-
getHorizontalMargin
public float getHorizontalMargin()- Overrides:
getHorizontalMargin
in classToast
-
getVerticalMargin
public float getVerticalMargin()- Overrides:
getVerticalMargin
in classToast
-
getDuration
public int getDuration()- Overrides:
getDuration
in classToast
-
getGravity
public int getGravity()- Overrides:
getGravity
in classToast
-
getXOffset
public int getXOffset()- Overrides:
getXOffset
in classToast
-
getYOffset
public int getYOffset()- Overrides:
getYOffset
in classToast
-
getView
-
getToast
-