Android Question BCToast/CustomView

Guenter Becker

Active Member
Licensed User
Good Day, hope you are well

just I am developing some custom views and I like to show a BCToast aut of the custom view.

I tried to initialize the BCToast.initialize(mbase.parent) but this throws an error like shown below. I need some help how to correct initialize the BCToast inside the custom Control (Initialize or DesignerCreateView).


Ini Example and Upper Part of Error Message:
*** Service (starter) Create ***

Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
    Try
        mBase = Base

        Tag = mBase.Tag
        mBase.Tag = Me 
        
        toast.Initialize(mBase.parent) ' <---------
' ######################################

** Service (starter) Start **

** Activity (main) Create (first time) **

Error occurred on line: 19 (BCToast)

java.lang.RuntimeException: java.lang.ClassCastException: TDDBar.TechDoc.tddbbar cannot be cast to android.widget.TextView

    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)

    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)

    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)

    at TDDBar.TechDoc.bctoast._initialize(bctoast.java:72)

    at java.lang.reflect.Method.invoke(Native Method)

    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)

    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)

    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)

    at java.lang.reflect.Method.invoke(Native Method)

    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)

    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)

    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:147)

    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)

    at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)

    at java.lang.reflect.Method.invoke(Native Method) ......
 

teddybear

Well-Known Member
Licensed User
Try to add Sleep(0) before doing toast.Initialize(mBase.parent)
 
Upvote 0

Guenter Becker

Active Member
Licensed User
Its working Thank you.
 
Upvote 0
Top