The BBCodeview allows to display texts in a variety of ways. Since it also contains a scrollview, it is ideal for displaying longer texts even in a small area.
In this case BBCodeViews should be used on several windows, which can be dragged around.
When trying to assign a text to BBCodeview, the following error always appears:
Somehow the TextEngine must be connected to BBCodeview after Loadlayout().
But how?
[Small Testproject attached]
In this case BBCodeViews should be used on several windows, which can be dragged around.
When trying to assign a text to BBCodeview, the following error always appears:
errormessage:
Error occurred on line: 192 (BBCodeView)
java.lang.NullPointerException: Attempt to invoke virtual method 'anywheresoftware.b4a.objects.collections.List b4a.example.bbcodeparser._parse(b4a.example.bbcodeparser, b4a.example.bbcodeparser$_bbcodeparsedata)' on a null object reference
at b4a.example.bbcodeview._parseanddraw(bbcodeview.java:136)
at b4a.example.bbcodeview._settext(bbcodeview.java:72)
at b4a.example.b4xmainpage._createinfowindow(b4xmainpage.java:198)
at b4a.example.b4xmainpage._showinfo(b4xmainpage.java:99)
at b4a.example.b4xmainpage._button1_click(b4xmainpage.java:79)
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:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7161)
at android.view.View.performClickInternal(View.java:7133)
at android.view.View.access$3500(View.java:804)
at android.view.View$PerformClick.run(View.java:27416)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7617)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private InfoWindowList As List
Private TextEngine As BCTextEngine
Private BBCodeView1 As BBCodeView
Private Action1 As B4XView
Private InfoWinPanel As B4XView
Private Label1 As B4XView
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
TextEngine.Initialize(Root)
InfoWindowList.Initialize
End Sub
Sub Button1_Click
ShowInfo(1, "aaaa [b]Testtext[/b] aaaa aaa.")
End Sub
Sub Button2_Click
ShowInfo(2, "bbb [b]AnotherText[/b] bbbb bbb.")
End Sub
Sub ShowInfo(Index As Int, Text1 As String )
If Index > InfoWindowList.size Then
Dim vx As B4XView = CreateInfoWindow(Index, "Window #" & Index, Text1, 300dip, 200dip)
Root.AddView(vx, 10dip, 10dip, vx.Width, vx.Height)
Private dvP As dragview
dvP.Initialize(Root, vx)
InfoWindowList.Add(vx)
Else
Dim vx As B4XView = InfoWindowList.get(Index -1)
vx.Visible = True
End If
End Sub
Sub CreateInfoWindow(Index As Int, Title As String, Text As String, ItemHeight As Int, ItemWidth As Int) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, ItemWidth, ItemHeight)
p.LoadLayout("infowindow")
Label1.Text = Title
Action1.Tag =Index
BBCodeView1.Text = Text
Return p
End Sub
Sub DvPanel_Action_Click
Dim vc As B4XView = Sender
Dim vx As B4XView = InfoWindowList.get(vc.Tag -1)
vx.Visible = False
End Sub
Somehow the TextEngine must be connected to BBCodeview after Loadlayout().
But how?
[Small Testproject attached]