Android Question updating label text in a loop

stachiwma

New Member
Licensed User
Longtime User
I'm missing something obvious. I was playing with the GPS example, and the section where the satellite information is being displayed in a label.. I copied that section of cod ein to a Boy Scout program Im working on, and for the life of me All it displays is "satellites:". Added logfile trackina dn the loop is executing.. What setting in the designer or what did I miss to set. The example program runs perfectly.
B4X:
Sub GPS_GpsStatus (Satellites As List)
    lblSatellites.Text = "Satellites:" & CRLF
    For i = 0 To Satellites.Size - 1
        Dim Satellite As GPSSatellite
        Satellite = Satellites.Get(i)
        Log("i="&i&" used in fix="&Satellite.UsedInFix&" prn#="&Satellite.Prn)
        lblSatellites.Text = lblSatellites.Text & CRLF & Satellite.Prn & _
            " " & Satellite.Snr & " " & Satellite.UsedInFix & " " & Satellite.Azimuth _
            & " " & Satellite.Elevation
    Next
End Sub

This is driving me crazy. Thanks

Dr. Mike
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Is your Label big enough to display all that text? If so, try using a StringBuilder to assemble your display text instead of directly adding it to the Label. Then, when it's all assembled, set the Label.Text = StringBuilder.toString.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I don't know what the problem is on your device.
I wrote a small test program with your code and it works !
Attached the test program.

As already suggested by Roycefer you should define a String variable and build the text in the loop and at the end set the lblSatellites.Text property like in the code in the GPSExample program.
 

Attachments

  • TestSatellites.zip
    7.7 KB · Views: 214
Upvote 0
Top