Android Question Multi Initialize in class module

Salar82

Member
Hi All

I want to use Initialize2+ in my class module; But I Get some error on This Line:
B4X:
Toast.Initialize2

B4X:
Error occurred on line: 31 (Main)
java.lang.RuntimeException: Class instance was not initialized (shmaterialtoast)
    at anywheresoftware.b4a.debug.Debug.shouldDelegate(Debug.java:242)
    at com.shmaterialtoast.shmaterialtoast._initialize2(shmaterialtoast.java:50)
    at com.shmaterialtoast.main._activity_create(main.java:384)
    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:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at com.shmaterialtoast.main.afterFirstLayout(main.java:104)
    at com.shmaterialtoast.main.access$000(main.java:17)
    at com.shmaterialtoast.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

How can i use it?

Thanks in advance for your reply
 
Last edited:

Salar82

Member
You must first call the Initialize (not 2) method. You can add parameters to this method.
thanks for your reply

I put the following sub in the class:
B4X:
Private Sub Initialize
  
End Sub

Private Sub IsInitialized
  
End Sub

And Chaneged Public Sub Initialize To Public InitializeClass:
B4X:
Public Sub InitializeClass(Some parameters)

now it works well
;););)
 
Last edited:
Upvote 0

Salar82

Member
ohhh
yes; you're right.

Sorry for Previous post


but the following class is correct:
B4X:
Private Sub Class_Globals
    Private xui As XUI
End Sub

Private Sub IsInitialized

End Sub

Public Sub ShowImageInWebView(WebView As WebView , Dir As String , FileName As String)
    WebView.LoadHtml($"<img src="${xui.FileUri(Dir, FileName)}"/>"$)
End Sub

it's true?
 
Upvote 0
Top