B4A Library DynamicToastLibrary

A (partly) wrap for this Github project. Sure you know what to do (no other lib files required other than the attached lib files - copy them to your additional library folder)

The complete B4A project has been zipped including the additional resources that are required (folder LibRes)

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDynamicToast
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dt As DynamicToast

    Private btnError As Button
    Private btnWarning As Button
    Private btnSuccess As Button
    Private btnInformation As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
    dt.Initialize
   

End Sub

Sub Activity_Resume
   
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnError_Click
   
    dt.ErrorMessageToast = "This is an error..."
   
End Sub

Sub btnWarning_Click
   
    dt.WarningMessageToast = "This is a warning..."
   
End Sub

Sub btnSuccess_Click
   
    dt.SuccessMessageToast = "This is a success..."
   
End Sub

Sub btnInformation_Click
   
    dt.InformationMessageToast = "This is information..."
   
End Sub

1.png



2.png



3.png


4.png



5.png
 

Attachments

  • DynamicToastLibFiles.zip
    8.5 KB · Views: 573
  • TheJavaCode.zip
    55 KB · Views: 449
  • b4aDynamicToast.zip
    456.5 KB · Views: 528

palmzac

Active Member
Licensed User
Longtime User
Hi Schoeman,

It's great. Would you add more options in this library ? ( e.g. position, duration )

Thank for your help !
 

Jaames

Active Member
Licensed User
Longtime User
Hi, there is extended version with MyCustomToast class.
Everything is the same as the OP , I just wrapped the MyCustomToast class.

Thanks @Johan Schoeman for sharing this.

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDynamicToast
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dt As DynamicToast
    Dim ct As CustomToast
   
    Private btnError As Button
    Private btnWarning As Button
    Private btnSuccess As Button
    Private btnInformation As Button
    Private btnCustom As Button
   

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
    dt.Initialize
    ct.Initialize
   


  
End Sub

Sub Activity_Resume
   
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnError_Click
   
    dt.ErrorMessageToast = "This is an error..."

   
End Sub

Sub btnWarning_Click
   
    dt.WarningMessageToast = "This is a warning..."
   
End Sub

Sub btnSuccess_Click
   
    dt.SuccessMessageToast = "This is a success..."
   
End Sub

Sub btnInformation_Click
   
    dt.InformationMessageToast = "This is information..."
   
End Sub

Sub btnCustom_Click
    ct.CustomMessageText = "custom toast message.."
    ct.CustomMessageTextColor = Colors.White
    ct.CustomMessageTextSize = 18
    ct.setCustomMessageIcon(ct.icon_INFO, ct.icon_POSITION_LEFT)
    ct.CustomMessageIconColor = Colors.White
    ct.CustomMessageBackgroundColor = 0xFF853657
    ct.CustomMessageBackgroundDrawable = ct.background_INFO
    ct.CustomMessageDuration = ct.LENGTH_LONG
    ct.setGravity(Gravity.CENTER,0,0)
   'ct.CustomMessageTypeface = Typeface.LoadFromAssets("cambriai.ttf") 'Download cambria font if you want it (google search) and put it in "Files" folder
    ct.CustomMessageTypeface = Typeface.CreateNew(Typeface.MONOSPACE,Typeface.STYLE_ITALIC)
    ct.Show
   
End Sub
ss2.png
 

Attachments

  • b4aDynamicToast.zip
    474 KB · Views: 413
  • LibFiles.zip
    10.9 KB · Views: 405
  • TheJavaCode.zip
    60.4 KB · Views: 373
Top