Android Question Problem construction string literal

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Trying to construct a smart string literal to be passed to a BBCodeView.
The BBCodeView needs to show items lined up in 2 columns, and I am using a TableRow Sub to construct this string.
Having a problem constructing this string literal and tried many variations, but so far not been successful.

Code should be something like this, just to construct the first row:

B4X:
Sub MakeStringLiteral

    Dim str As String

    str = $"
${TableRow(${Array As String("App version", ${strVersion})})}
"$
   
End Sub

Sub TableRow(arrFields() As String) As String
   
    Select Case arrFields.Length
        Case 1
            Return $"
[Span MinWidth=100%x Alignment=center]${arrFields(0)}[/Span]"$
        Case 2
            Return $"
[Span MinWidth=50%x Alignment=center]${arrFields(0)}[/Span]
[Span MinWidth=50%x Alignment=center]${arrFields(1)}[/Span]"$
        Case 3
            Return $"
[Span MinWidth=33%x Alignment=center]${arrFields(0)}[/Span]
[Span MinWidth=33%x Alignment=center]${arrFields(1)}[/Span]
[Span MinWidth=33%x Alignment=center]${arrFields(2)}[/Span]"$
        Case 4
            Return $"
[Span MinWidth=25%x Alignment=center]${arrFields(0)}[/Span]
[Span MinWidth=25%x Alignment=center]${arrFields(1)}[/Span]
[Span MinWidth=25%x Alignment=center]${arrFields(2)}[/Span]
[Span MinWidth=25%x Alignment=center]${arrFields(3)}[/Span]"$
        Case 5
            Return $"
[Span MinWidth=20%x Alignment=center]${arrFields(0)}[/Span]
[Span MinWidth=20%x Alignment=center]${arrFields(1)}[/Span]
[Span MinWidth=20%x Alignment=center]${arrFields(2)}[/Span]
[Span MinWidth=20%x Alignment=center]${arrFields(3)}[/Span]
[Span MinWidth=20%x Alignment=center]${arrFields(4)}[/Span]"$
        Case Else
            Return ""
    End Select
   
End Sub

Any advice how this can be done?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
B4X:
str = $"
${TableRow(Array As String("App version", strVersion))}
"$
or don't need to use String Literal here.
Thanks, that works fine indeed.
I understood wrongly that every variable or function needed placeholders.
This is a lot simpler now.

RBS
 
Upvote 0
Top