I already have a rather complex program (B4XPages) in which among other things I want to display messages from different modules using a subroutine located in one of these modules.
In B4A, an error was received with the message "java.lang.NullPointerException: null receiver". Then I decided to make a simplified program with the same task. As a result, this simplified program gives me error message on the same line, but this time the message is different (both in B4A and B4J):
P.S.
In B4A, an error was received with the message "java.lang.NullPointerException: null receiver". Then I decided to make a simplified program with the same task. As a result, this simplified program gives me error message on the same line, but this time the message is different (both in B4A and B4J):
Error occurred on line: 36 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (B4XView).
B4XMainPage:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
' Private Activity As Activity
Public Label1 As B4XView
Private Cl As Class1
End Sub
Public Sub Initialize
Cl.Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
sub_Info ("Message from B4XMainPage")
Cl.Sub_in_Class1
End Sub
Public Sub sub_Info (Message As String)
Label1.Text = Label1.Text & Message & CRLF <---------- This line causes the error
End Sub
Class1:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private MainPage As B4XMainPage
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
End Sub
Public Sub Sub_in_Class1
MainPage.Initialize
MainPage.sub_Info ("Message from Class1")
End Sub
P.S.
Attachments
Last edited: