Android Question Question about CSBuilder

Matteo Giorgini

Member
Licensed User
Hi guys!
Today I've this strange problem with CSBuilder.
In a code module I wrote this function:

B4X:
Public Sub GetTitleProductReplace As String
    Dim sf1 As StringFunctions
    Dim cs1 As CSBuilder

    sf1.Initialize
    cs1.Initialize
    cs1.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE86A)).Typeface(Typeface.DEFAULT).Append(sf1.AddSpaces(3))
    cs1.Typeface(Typeface.DEFAULT).Append("MyText").PopAll
    cs1.PopAll
    Return cs1
End Sub
I don't understand why the icon not render correctly.

I use this to set "text" property of a Label loaded dinamycally from layout, during custom dialog's build.

If I write the same code "in-line" icon render correctly.

B4X:
    Dim cs As CSBuilder
    Dim sf1 As StringFunctions
    sf1.Initialize
    cs.Initialize
    cs.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE86A)).Typeface(Typeface.DEFAULT).Append(sf1.AddSpaces(3))
    cs.Typeface(Typeface.DEFAULT).Append("MyText").PopAll
    
    LabelProductReplaceTitle.Text = cs ' FunctionsCommonSoL.GetTitleProductReplace
In others same context (for example, to set "text" property of another Label loaded dinamycally from layout, but not during custom dialog's build), works correctly: icon is correctly rendered.

Have you got an idea?

Thanks in advance

Matteo
 

udg

Expert
Licensed User
I don't know if that is the cause of your problem, but first example shows two PopAll instructions for the same cs.
Using StringFunctions to add three spaces isn't it a bit too much?
Why not a Pop after the first block? I eman:
B4X:
cs.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE86A)).Pop.Typeface(Typeface.DEFAULT).Append(sf1.AddSpaces(3)).Pop
cs.Typeface(Typeface.DEFAULT).Append("MyText").PopAll
Note that since you're using the same Default font for spaces and text you don't need to redeclare the typeface.
 

Matteo Giorgini

Member
Licensed User
Hi udg!
Thanks for your suggest, but I've got same problem.
With same code block, on code module don't works, in-line works.

in-line code:
    Dim cs1 As CSBuilder
    Dim sf1 As StringFunctions
    sf1.Initialize
    cs1.Initialize
    cs1.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE86A)).Pop.Append(sf1.AddSpaces(3))
    cs1.Typeface(Typeface.DEFAULT).Append("TITLE").PopAll
    LabelProductReplaceTitle.Text = cs1
Module code:
Public Sub GetTitleProductReplace As String
    Dim cs1 As CSBuilder
    Dim sf1 As StringFunctions
    sf1.Initialize
    cs1.Initialize
    cs1.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE86A)).Pop.Append(sf1.AddSpaces(3))
    cs1.Typeface(Typeface.DEFAULT).Append("TITLE").PopAll
    Return cs1
End Sub
I'm curious to find the solution...

Matteo
 

udg

Expert
Licensed User
I was logging in when Erel replied. Quicker than me by seconds..eheh
 
Top