Italian [risolto] [b4a] label B4XView creata da codice perché mi da errore!!!!

ivanomonti

Expert
Licensed User
Longtime User
MI SENTO UN CRETINO MA FORSE LO SONO ... dove sbaglio

B4X:
        Dim lb As B4XView
        lb.As(Label).Text = "Q: " & message
        lb.As(Label).SingleLine=False
        ListView1.AddView(lb,0dip,0dip,100dip,30dip)
       
        Dim lb As B4XView
        lb.Text = "A: " & datasend
        lb.As(Label).SingleLine=False
        ListView1.AddView(lb,0dip,0dip,100dip,30dip)


B4X:
Error occurred on line: 95 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User

[b4a] label B4XView creata da codice perché mi da errore!!!!​

Perché gli sei antipatico, è ovvio!
?

Dim lb As B4XView
Devi dichiararla come hai fatto, ma deve esistere; o in un layout caricato o creata da te come Label:
B4X:
Dim lb As B4XView

Dim MyLabel As Label
MyLabel.Initialize("")
lb = MyLabel

Una B4XView è un contenitore di una view "normale".
 
Top