Android Question [Solved] BBCodeView Error

Chris Guanzon

Active Member
Licensed User
Longtime User
Hello everyone, I have a problem with bbcodeview. The error is below:

B4X:
Error occurred on line: 201 (BBCodeView)
java.lang.NullPointerException: Attempt to invoke virtual method 'anywheresoftware.b4a.objects.collections.List com.aam.us.crg.bbcodeparser._parse(com.aam.us.crg.bbcodeparser, com.aam.us.crg.bbcodeparser$_bbcodeparsedata)' on a null object reference
    at com.aam.us.crg.bbcodeview._parseanddraw(bbcodeview.java:195)
    at com.aam.us.crg.bbcodeview._settext(bbcodeview.java:131)
    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 anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1770)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6251)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

I already initialized the TextEngine before I add a text in BBCodeView. The error occurs in BBCodeView.Text
 

mfstuart

Active Member
Licensed User
Longtime User
Hi Chris,
I'm having the same issue. How did you fix it?

I set the Engine inside the Activity_Create

B4X:
    bcEngine.Initialize(Activity)    
    bbAccounts_Delete_CSV.AutoUnderlineURLs = True
    bbAccounts_Delete_CSV.Text = $"[url]Delete CSV File[/url]"$       'crashes here
    bbAccounts_Delete_CSV.Redraw
 
Upvote 0

mfstuart

Active Member
Licensed User
Longtime User
It seems this is the answer/fix to the issue I was having...

B4X:
    bcEngine.Initialize(Activity)
    bbAccounts_Delete_CSV.TextEngine = bcEngine    'make sure you add this here
    bbAccounts_Delete_CSV.AutoUnderlineURLs = True
    bbAccounts_Delete_CSV.Text = $"[url]Delete CSV File[/url]"$       'will not crash now
    bbAccounts_Delete_CSV.Red
 
Upvote 0
Top