Name: TD_Toast
Type: custom B4A Class or b4xlib
Version: 1
This custom class subtitutes the standard android toast message. The benefits are:
The Toast creates a Type Vaiable TDToast and a public Variable ToastGUI.
Type TDToast ( _
Category As String, Duration As Int, _
Width As Int, height As Int, Top As Int, Color As Int, _
Bordercolor As Int, Borderwidth As Int, Borderradius As Int, _
IconFile As String, IconWidth As Int, IconHeight As Int, _
Text As String, Textcolor As Int, Textsize As Int, _
click As Boolean)
The default duration for themed toasts is 3000ms. All needed Icons are inbuild.
Before shown the toast view is added to the parent (B4XPage) and it is removed if the the toast goes hidden.
To show the Toast:
TD_Toast1.showtoast(Category As String, Text As String, IconFile As String,click As Boolean)
Category -Themed- : attention / info / error /question/sucess
Category -individual- : gray
Category -special - : spinner as loading indicator
Text: The text shown may be a single ore multiline text. CSBuilder recomended.
IconFile: Tehe Filename if categroy is gray otherwhise empty ""
click: If True the toast is displayed until it is clicked.
To hide the toast manually:
TD_Toast1.killToast
To customize the toast:
Before calling showToast set the individual values to the variable Public ToastGUI As TDToast (TD_Toast1.ToastGUI....)
To click the toast:
If you click on the Toast the custom event _click raises (TD_Toast1_Click)
If you customize the ToastGUI you will be able to make every toast static/clickable or not.
Type: custom B4A Class or b4xlib
Version: 1
This custom class subtitutes the standard android toast message. The benefits are:
- Customizable GUI
- Timed out Message or static until clicked
- Inbuild Themes
| Theme Attention Toast |
Theme Info Toast | |
Theme Question Toast, | |
Theme SuccessToast | |
Theme Error Toast | |
Individual Toast | |
Theme Loading Indicator Toast |
- Download Example Project from here Download
- Install Class in your project or copy TD_Toast.b4xlib to your additional lib folder and activate lib in lib pane.
- Activate this libs B4XGifView, StringUtils, XUI
- Create a Reference in the Class_Globals of the page like Private TD_Toast1 as TD_Toast
Initialize the Toast object:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Sleep(0)
'# Initialize Class
'# Allways Me, Allways Root, eventname
TD_Toast1.Initialize(Me,Root,"TD_Toast1")
End Sub
The Toast creates a Type Vaiable TDToast and a public Variable ToastGUI.
Type TDToast ( _
Category As String, Duration As Int, _
Width As Int, height As Int, Top As Int, Color As Int, _
Bordercolor As Int, Borderwidth As Int, Borderradius As Int, _
IconFile As String, IconWidth As Int, IconHeight As Int, _
Text As String, Textcolor As Int, Textsize As Int, _
click As Boolean)
The default duration for themed toasts is 3000ms. All needed Icons are inbuild.
Before shown the toast view is added to the parent (B4XPage) and it is removed if the the toast goes hidden.
To show the Toast:
TD_Toast1.showtoast(Category As String, Text As String, IconFile As String,click As Boolean)
Category -Themed- : attention / info / error /question/sucess
Category -individual- : gray
Category -special - : spinner as loading indicator
Text: The text shown may be a single ore multiline text. CSBuilder recomended.
IconFile: Tehe Filename if categroy is gray otherwhise empty ""
click: If True the toast is displayed until it is clicked.
To hide the toast manually:
TD_Toast1.killToast
To customize the toast:
Before calling showToast set the individual values to the variable Public ToastGUI As TDToast (TD_Toast1.ToastGUI....)
To click the toast:
If you click on the Toast the custom event _click raises (TD_Toast1_Click)
If you customize the ToastGUI you will be able to make every toast static/clickable or not.