Android Code Snippet [B4X] BCTextEngine - Create Named Link

Alexander Stolte

Expert
Licensed User
CreateNamedLink:
Public Sub CreateNamedLink(name As String,url As String,color As String) As String
    Return "[b][url=""" & url & """][color=" & color & "]" & name & "[/color][/url][/b]"
End Sub
usage:
bbcv.Text = "[Alignment=Center]" & "Bitte " & CreateNamedLink("Anmelden","https://yourniceurl","#2D8879") & "/" & CreateNamedLink("Registrieren","https://yourniceurl","#2D8879") & " um ein kommentar zu schreiben" & "[/Alignment]"
Screenshot_20200601-210821.jpg
 

Erel

Administrator
Staff member
Licensed User
I wouldn't have created the BBCode parser if there wasn't support for smart strings in B4X:
B4X:
Public Sub CreateNamedLink(name As String,url As String,color As String) As String
    Return $"[b][url="${url}"][color=${color}]${name}[/color][/url][/b]"$
End Sub

BBCodeView1.Text = $"[Alignment=Center]Bitte ${CreateNamedLink("Anmelden","https://yourniceurl","#2D8879")}/${CreateNamedLink("Registrieren","https://yourniceurl","#2D8879")} um ein kommentar zu schreiben[/Alignment]"$
 
Top