Android Question How to display multiple Toastmessageshow in the order it is written...

beelze69

Active Member
Licensed User
Longtime User
Hi,

I have multiple ToastMessageShow entries in my code..

However, only the last ToastMessageShow is shown during execution..

How should we ensure that the ToastMessageShow entries are executed in the order it is written ?

Requesting for guidance with an example...

Thanks..
 

beelze69

Active Member
Licensed User
Longtime User
Use BCToasts; you can set their duration (property: DurationMs) and write a Sleep(SameDuration) after showing them.
B4X:
Dim Toast As BCToast
Toast.Initialize(Root)  ' or Toast.Initialize(Activity.As(B4XView)) if your are not using B4XPages.
Toast.DurationMs = 1500
Toast.Show("Message")
Sleep(1500)
Thanks Lucas..

Will try this out..

But can't we do something like Wait For with ToastMessageShow ? ...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Thanks Lucas..

Will try this out..

But can't we do something like Wait For with ToastMessageShow ? ...
No, because it doesn't raise an event when it completes its "job".

P.S. You could do something like this:
B4X:
Private Sub Button1_Click
    Wait For (ShowToast("First toast message", 1500)) Complete(Unused As Boolean)
    Wait For (ShowToast("Second toast message", 1500)) Complete(Unused As Boolean)
End Sub

Sub ShowToast(Message As String, Duration As Int) As ResumableSub
    Dim Toast As BCToast
    Toast.Initialize(Root)   ' or Toast.Initialize(Activity.As(B4XView)) if your are not using B4XPages.
    Toast.DurationMs = Duration
    Toast.Show(Message)
    Sleep(Duration)
    Return True
End Sub
 
Last edited:
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
No, because it doesn't raise an event when it completes its "job".

P.S. You could do something like this:
B4X:
Private Sub Button1_Click
    Wait For (ShowToast("First toast message", 1500)) Complete(Unused As Boolean)
    Wait For (ShowToast("Second toast message", 1500)) Complete(Unused As Boolean)
End Sub

Sub ShowToast(Message As String, Duration As Int) As ResumableSub
    Dim Toast As BCToast
    Toast.Initialize(Root)   ' or Toast.Initialize(Activity.As(B4XView)) if your are not using B4XPages.
    Toast.DurationMs = Duration
    Toast.Show(Message)
    Sleep(Duration)
    Return True
End Sub
Hi Lucas,

Thanks !

Will try this out...
 
Upvote 0
Top