Class ToastCompat


  • public final class ToastCompat
    extends android.widget.Toast
    A Toast to fix the bad token exception on API 25.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class android.widget.Toast

        android.widget.Toast.Callback
    • Field Summary

      • Fields inherited from class android.widget.Toast

        LENGTH_LONG, LENGTH_SHORT
    • Constructor Summary

      Constructors 
      Constructor Description
      ToastCompat​(android.content.Context context, android.widget.Toast base)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getDuration()  
      int getGravity()  
      float getHorizontalMargin()  
      android.widget.Toast getToast()  
      float getVerticalMargin()  
      android.view.View getView()  
      int getXOffset()  
      int getYOffset()  
      static android.widget.Toast makeText​(android.content.Context context, int resId, int duration)
      Make a standard toast that just contains a text view.
      static ToastCompat makeText​(android.content.Context context, java.lang.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 setText​(java.lang.CharSequence s)  
      void setView​(android.view.View view)  
      void show()  
      • Methods inherited from class android.widget.Toast

        addCallback, cancel, removeCallback
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ToastCompat

        public ToastCompat​(android.content.Context context,
                           @NonNull
                           android.widget.Toast base)
    • Method Detail

      • makeText

        public static ToastCompat makeText​(@NonNull
                                           android.content.Context context,
                                           @Nullable
                                           java.lang.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, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The standard toast that just contains a text view.
      • makeText

        public static android.widget.Toast makeText​(@NonNull
                                                    android.content.Context context,
                                                    @StringRes
                                                    int resId,
                                                    int duration)
                                             throws android.content.res.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, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The standard toast that just contains a text view.
        Throws:
        android.content.res.Resources.NotFoundException
      • show

        public void show()
        Overrides:
        show in class android.widget.Toast
      • setDuration

        public void setDuration​(int duration)
        Overrides:
        setDuration in class android.widget.Toast
      • setGravity

        public void setGravity​(int gravity,
                               int xOffset,
                               int yOffset)
        Overrides:
        setGravity in class android.widget.Toast
      • setMargin

        public void setMargin​(float horizontalMargin,
                              float verticalMargin)
        Overrides:
        setMargin in class android.widget.Toast
      • setText

        public void setText​(int resId)
        Overrides:
        setText in class android.widget.Toast
      • setText

        public void setText​(java.lang.CharSequence s)
        Overrides:
        setText in class android.widget.Toast
      • setView

        public void setView​(android.view.View view)
        Overrides:
        setView in class android.widget.Toast
      • getHorizontalMargin

        public float getHorizontalMargin()
        Overrides:
        getHorizontalMargin in class android.widget.Toast
      • getVerticalMargin

        public float getVerticalMargin()
        Overrides:
        getVerticalMargin in class android.widget.Toast
      • getDuration

        public int getDuration()
        Overrides:
        getDuration in class android.widget.Toast
      • getGravity

        public int getGravity()
        Overrides:
        getGravity in class android.widget.Toast
      • getXOffset

        public int getXOffset()
        Overrides:
        getXOffset in class android.widget.Toast
      • getYOffset

        public int getYOffset()
        Overrides:
        getYOffset in class android.widget.Toast
      • getView

        @Nullable
        public android.view.View getView()
        Overrides:
        getView in class android.widget.Toast
      • getToast

        @NonNull
        public android.widget.Toast getToast()