Android Question Problem with GPS speed display

billborric

Member
Licensed User
Longtime User
Hi,
I'm getting the GPS speed in m/sec and converting to Kmh. No matter what I try when I get to 100Kmh or above it will only display the first 2 digits (10).
I have tried hard code 100 and it displays 100.
I have checked that the m/sec figure is correct and it is.
I have tried Round and NumberFormat and each display the same 2 digits at 100, ie 10.
The speed figure is assigned to the big label shown in the designer.
I'm at a loss. Hope someone can help.

B4X:
   lblSpeed.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT)
   Dim iSpeed As Int
   Dim cSpeed As String
   iSpeed = NumberFormat((Location1.Speed*3.6),0,0)
   cSpeed = iSpeed
   'lblSpeed.Text = $"$1.2{Round(Location1.Speed*3.6)}"$
   lblSpeed.Text = cSpeed
designer.png
 

Ed Brown

Active Member
Licensed User
Longtime User
If you use LOG(cSpeed) what do you see? Is it the same? If it is not then the font size might be too high and the last digit might be overflowing onto a new line.
Also, I have had some display issues with NumberFormat in the past and replaced using it with NumberFormat2.
 
Upvote 0

billborric

Member
Licensed User
Longtime User
Hi Ed,

Well a smaller font fixed the problem. But I cannot figure out why a hard coded 100 displayed OK and the calculated one (even trimmed) would not.
Any how all fixed and able to move on now.

Thanks.
 
Upvote 0
Top