Package totalcross.ui

Class Toast


  • public class Toast
    extends java.lang.Object
    Class used to show a message on screen.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int backColor
      Back color used in the toast.
      static int buttonHGap
      Gap between the text and the button, horizontally
      static int buttonVGap
      Gap between the text and the button, vertically.
      static Container cnt
      The toast component used to show the text.
      static int extraW
      Extra width of the toast in font's height multiples.
      static int fade
      The stopping fade value, used on transparency.
      static Font font
      The font to be used.
      static int foreColor
      Fore color used in the toast.
      static int height
      Height of the toast.
      static int INFINITE  
      static int INFINITE_NOANIM  
      static int paddingBottom
      Padding of the component.
      static int paddingLeft
      Padding of the component.
      static int paddingRight
      Padding of the component.
      static int paddingTop
      Padding of the component.
      static int posX
      X position of the toast.
      static int posY
      Y position of the toast.
      static int width
      Width of the toast.
    • Constructor Summary

      Constructors 
      Constructor Description
      Toast()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void show​(java.lang.String message, int delay)
      Shows a toast message using the given parameters on the main window.
      static void show​(java.lang.String message, int delay, java.lang.String buttonCaption, int buttonForeColor, PressListener btnPressListener)
      Shows a toast message with a button using the given parameters on the main window.
      static void show​(java.lang.String message, int delay, Window parentWindow)
      Shows a toast message using the given parameters on the given window.
      static void show​(java.lang.String message, int delay, Window parentWindow, java.lang.String buttonCaption, int buttonForeColor, PressListener btnPressListener)
      Shows a toast message with a button using the given parameters on the given window.
      static void stopShow()
      Unpop the Toast from the screen.
      static void stopShow​(boolean animate)
      Unpop the Toast from the screen.
      • Methods inherited from class java.lang.Object

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

      • backColor

        public static int backColor
        Back color used in the toast.
      • foreColor

        public static int foreColor
        Fore color used in the toast.
      • posX

        public static int posX
        X position of the toast. Defaults to CENTER.
      • posY

        public static int posY
        Y position of the toast. Defaults to BOTTOM - fmH.
      • extraW

        public static int extraW
        Extra width of the toast in font's height multiples. Defaults to 2.
      • width

        public static int width
        Width of the toast. Defaults to PREFERRED.
      • height

        public static int height
        Height of the toast. Defaults to PREFERRED.
      • fade

        public static int fade
        The stopping fade value, used on transparency. Defaults to 200.
      • font

        public static Font font
        The font to be used. Defaults to the default bold font.
      • paddingLeft

        public static int paddingLeft
        Padding of the component.
      • paddingRight

        public static int paddingRight
        Padding of the component.
      • paddingTop

        public static int paddingTop
        Padding of the component.
      • paddingBottom

        public static int paddingBottom
        Padding of the component.
      • buttonHGap

        public static int buttonHGap
        Gap between the text and the button, horizontally
      • buttonVGap

        public static int buttonVGap
        Gap between the text and the button, vertically. Used when the button text is too big.
      • cnt

        public static Container cnt
        The toast component used to show the text.
    • Constructor Detail

      • Toast

        public Toast()
    • Method Detail

      • show

        public static void show​(java.lang.String message,
                                int delay)
        Shows a toast message using the given parameters on the main window.
        See Also:
        show(String, int, Window)
      • show

        public static void show​(java.lang.String message,
                                int delay,
                                Window parentWindow,
                                java.lang.String buttonCaption,
                                int buttonForeColor,
                                PressListener btnPressListener)
        Shows a toast message with a button using the given parameters on the given window.
      • show

        public static void show​(java.lang.String message,
                                int delay,
                                java.lang.String buttonCaption,
                                int buttonForeColor,
                                PressListener btnPressListener)
        Shows a toast message with a button using the given parameters on the main window.
        See Also:
        #show(String, int, Window, String, PressListener)
      • show

        public static void show​(java.lang.String message,
                                int delay,
                                Window parentWindow)
        Shows a toast message using the given parameters on the given window. Sample:
         String message = "This is a test";
         Toast.show("\n"+message+"\n", 2000);
         
        See the public static fields of this class to show how you can customize the appearance. Calling with a nulled message will make the last toast disappear. The text is splitted if wider than the screen. If delay is INFINITE, it will wait forever until you call stopShow(). If delay is INFINITE_NOANIM, it will wait forever until you call stopShow() and will not use animation.
      • stopShow

        public static void stopShow()
        Unpop the Toast from the screen. If you don't want the animation of fading out, please call stopShow(false) instead.
      • stopShow

        public static void stopShow​(boolean animate)
        Unpop the Toast from the screen.
        Parameters:
        animate - Animate the Toast with fading out.