Android Question [SOLVED] I got a strange error with BCToast

bsnqt

Active Member
Licensed User
Longtime User
I can customize and use the BCToast quite successfully. But everytime when my app goes to the background (paused) then comes back, I could not show the toast again. I don't know what is wrong here?

Here is the error:
(NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.B4XViewWrapper.setColor(int)
on a null object reference

My code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        bctoast.Initialize(toastPanel)    ' toastPanel is the toast parent view
    End If
End Sub   

Sub ShowBCToast(message As String, fontcolor As String, backgrcolor As Int)
    ' Example for the color => "color=#ff00ff" Or "color=White"
    bctoast.DurationMs = 4000
    bctoast.PaddingTopBottom = 10dip
    bctoast.VerticalCenterPercentage = 50
    bctoast.pnl.Color = backgrcolor
    bctoast.Show($"[Alignment=Center][TextSize=16][b][${fontcolor}]${message}[/color][/b][/TextSize][/Alignment]"$)
End Sub

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
Initialize it always. Not only when FirstTime is true
 
Upvote 3
Solution
Top