Android Question Is this a bug - Trying to have a space at end of a string?

woodpecker

Member
Licensed User
Longtime User
Trying to set the text of panel to a word with a space followed by a variable seems to result in the variable not being display, is this a bug or something I'm doing wrong?

B4X:
pnl1.Text = "Distance " & DtoTarget

Only displays Distance and no varable.

This works but I want a space after the word.

B4X:
pnl1.Text = "Distance" & DtoTarget

Also tried using & Chr(32) same result???
 

DonManfred

Expert
Licensed User
Longtime User
pnl1.Text = "Distance " & DtoTarget
does work for me like expected. For sure i need a LABEL not a panel. a Panel does not have a Text property.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
    
    Dim distance As String = "5 miles"
    Label1.Text = "Distance "&distance
    
End Sub

WhatsApp Image 2018-06-21 at 13.14.54.jpeg
 
Upvote 0

woodpecker

Member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
   
    Dim distance As String = "5 miles"
    Label1.Text = "Distance "&distance
   
End Sub

View attachment 69146

I think there was something weird with my variable, it now seems to work ok, it was a label, I confused myself calling in pnl etc
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Perhaps your label width is not enough to accommodate the text plus the number and it is wrapping to a 2nd line at the space character?
 
Upvote 0
Top