Android Tutorial [B4X] BBCodeView Anchors Example

1684912822081.png
1684912838657.png


A small, cross platform, example of using the new anchors feature of BBCodeView.

It reads a CSV file with information about US politicians. The data is used to populate a BBCodeView and B4XDialog+B4XSearchTemplate.

The bbcode looks like:
B4X:
For Each pol As Politician In politicians
        sb.Append($"
[a="${pol.Name}"][b][TextSize=18]${pol.Name}[/TextSize][/b][/a]
    Twitter: [url]@${pol.TwitterUserName}[/url]
    Birthday: $Date{pol.Birthday}
    ${pol.Party}
"$)
    Next
Note the "a" tag at the beginning.

The anchors are used in this code:
B4X:
Private Sub btnJumpTo_Click
    Wait For (dialog.ShowTemplate(SearchTemplate, "", "", "Cancel")) Complete (result As Int)
    If result = xui.DialogResponse_Positive Then
        BBCodeView1.ScrollToAnchor(SearchTemplate.SelectedItem)
    End If
End Sub

The generated bbcode text can get quite large. I wouldn't use BBCodeView like this with a larger dataset.
 

Attachments

  • Anchors2.zip
    449.9 KB · Views: 339
Last edited:
Top