B4A Library Tasty Toast

A wrap for this Github project.













Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: TastyToast - Wrapped by Johan Schoeman
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'#AdditionalRes: ..\resource
#AdditionalRes: ..\resource_tastytoast

'IMPORTANT!!!! YOU NEED TO SET THIS PATH CORRECTLY FOR YOUR OWN COMPUTER!!!!!!!!!!!!!!!!!!
'THE BELOW PATH IS THE PATH FOR MY COMPUTER
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
'#Extends: android.support.v7.app.AppCompatActivity

#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 tt As TastyToast
   
   
    Private btnSuccess As Button
    Private btnWarning As Button
    Private btnError As Button
    Private btnInfo As Button
    Private btnDefault 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")

    tt.Initialize

   
End Sub

Sub Activity_Resume
   
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnSuccess_Click
   
    tt.showSuccessToast("Download Successful !")
   
End Sub

Sub btnWarning_Click
   
    tt.showWarningToast("Are you sure ?")
   
End Sub

Sub btnError_Click
   
    tt.showErrorToast("Downloading failed ! Try again later ")
   
End Sub

Sub btnInfo_Click
   
    tt.showInfoToast("Searching for username : 'Johan' ")
   
End Sub

Sub btnDefault_Click
   
    tt.showDefaultToast("This is Default Toast")
   
End Sub
 

Attachments

  • b4aTastyToast.zip
    445.2 KB · Views: 576
  • TastyToastLibFiles.zip
    55.9 KB · Views: 577
  • TheJavaCode.zip
    46 KB · Views: 414

Mashiane

Expert
Licensed User
Longtime User
So brilliant... Now I'm convinced you are an alien from an intelligent light source somewhere...
 

Reids

Member
Licensed User
Longtime User
This is awesome!, but I need duration more longer in milisecond somehow
 

Johan Schoeman

Expert
Licensed User
Longtime User
This is awesome!, but I need duration more longer in milisecond somehow
The library makes use of the default toast class where the duration is either short(2000ms) or long (3500ms). The simplest solution with the lib as it is will be to call the toast twice eg
B4X:
    tt.showSuccessToast("Download Successful !")
tt.showSuccessToast("Download Successful !")

It might cause a slight blink but it is a solution....
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…