Android Code Snippet Tip: CSBuilder usage

A small point about CSBuilder.
You cannot mix CSBuilder objects with 'standard' text because the formatting will be lost.
This works as expected:
B4X:
    cs.Initialize.Append("Hello ")
    cs.Color(Colors.Blue).Append("world!").Pop
    lbl.Text = cs
but this removes all formatting:
B4X:
    cs.Initialize.Append("Hello ")
    cs.Color(Colors.Blue).Append("world!").Pop
    lbl.Text = cs & " "
 

Mahares

Expert
Licensed User
You cannot mix CSBuilder objects with 'standard' text because the formatting will be lost.
If you want to preserve the formatting, simply do this: cs=cs.Append(" ") instead of this: lbl.Text = cs & " "
B4X:
cs.Initialize.Append("Hello ")
    cs.Color(Colors.Blue).Append("world!").Pop
    lbl.Text = cs=cs.Append(" ")
 
Top