Android Code Snippet [B4X] BCTextEngine - Create Named Link

[CODE lang="b4x" title="CreateNamedLink"]Public Sub CreateNamedLink(name As String,url As String,color As String) As String
Return "[color=" & color & "]" & name & "[/color]"
End Sub[/CODE]

[CODE lang="b4x" title="usage"]bbcv.Text = "[Alignment=Center]" & "Bitte " & CreateNamedLink("Anmelden","https://yourniceurl","#2D8879") & "/" & CreateNamedLink("Registrieren","https://yourniceurl","#2D8879") & " um ein kommentar zu schreiben" & "[/Alignment]"[/CODE]
Screenshot_20200601-210821.jpg
 
I wouldn't have created the BBCode parser if there wasn't support for smart strings in B4X:
Code:
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]"$
 
Back
Top