B4A Library [B4X] BCToast - Cross platform custom toast message

Star-Dust

Expert
Licensed User
Longtime User
I remember that one day you said that if it works at least for two platforms [B4X] is OK.
But I don't remember the thread.
in this thread

But I think Erel's concept is that if it isn't specified that it only affects 2 platforms (obviously indicating which ones) then it is meant for 3.
 
Last edited:

Jorge M A

Well-Known Member
Licensed User
Longtime User
[B4X] B4XDrawer - sliding drawer
Works only with B4A and B4i, but not with B4J !?
eeeeeemmmmm.....
Updates:

- 1.53 - Adds support for B4J (without gestures). No need to update if using with B4A or B4i.
 

klaus

Expert
Licensed User
Longtime User
But I think Erel's concept is that if it isn't specified that it only affects 2 platforms (obviously indicating which ones) then it is meant for 3.
I totally agree with this too!
I'm afraid that I didn't read carefully enough the [B4X] B4XDrawer - sliding drawer thread where it is written that the B4J version was added.
 

bocker77

Active Member
Licensed User
Longtime User
Is there a way to change the width of the toast panel. I tried changing the width as such but with no effect.
"toast.pnl.Width = Activity.Width - 100dip" and many other values. When I show it it fills the whole width of the screen. I would like to limit the width and it looks as if I can implement wordwrap with BB1 if the text is too long.

Thanks
 

bocker77

Active Member
Licensed User
Longtime User
Not to sound too stupid but I am not quite sure I understand what you mean. Here is my code surrounding this issue. pnlMain is the panel that the toast is being shown over if that comes into play in any way. Is this what you mean by parent view?

B4X:
    Private toast As BCToast
    Dim xui As XUI
... 
    Private pnlMain As Panel
...
        ' Setup Custom Toast Message
        toast.Initialize(Activity)
        toast.VerticalCenterPercentage = 65
        toast.pnl.Width = Activity.Width - 100dip
        toast.BB1.TextEngine.Initialize(Activity)
        toast.BB1.WordWrap = True
        toast.BB1.TextEngine.CustomFonts.Put("normal",xui.CreateFont(Typeface. _
                                             CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL), 10))
...
        ' The maximum width = the width of the parent view. You can add it to a panel
        ' instead of the root view and make it thinner.
        toast.pnl.Color = Color
        toast.DurationMs = Duration
        toast.MaxHeight = 100dip
        toast.Show("[Alignment=Center][img FileName=SmallKanga.png width=24 vertical=12/][/Alignment]" & _
                "[Font=normal] [TextSize=14][Color=" & TextColor & "][Alignment=Left]" & CRLF & Text & _
                "[/Alignment][/Color][/TextSize][/Font]")
 

LucaMs

Expert
Licensed User
Longtime User
toast.Initialize(Activity) 'Use Page1.RootPanel in B4i or MainForm.RootPane in B4J.
Just a little clarification:

1 - you should change MainForm declaration to Public
2 - for B4Xpages other than B4XMainPage you shoud use something like:
B4X:
Dim frm As Form = B4XPages.GetNativeParent(Me)
toast.Initialize(frm.RootPane)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…