Android Question Problem with Label Text and Edit text Text

stu14t

Active Member
Licensed User
Longtime User
I have a problem with some labels and edittexts

I'm sure it's my fault but I can't seem to work out what is happening.

The original labels and Edittexts were created within the designer and not via code. They are not initialized within the code

The views show GPS information and I allow the user to switch from Lat / long to OSGB using a toggle button. The problem is the text doesn't change when I toggle and the GPS coordinates are supposed to change under the GPS_LocationChange event, updating two EditText's.

When I use the debugger, all the data in the Global Variables is correct and shows the appropriate values. However, the views do not update (I'm debugging on Samsung Galaxy S4 via B4A Bridge)
 

stu14t

Active Member
Licensed User
Longtime User
@DonManfred This is the code for the toggle button and it should change the labels from Lat & Long to Eastings and Northings

B4X:
Sub Tgl1_CheckedChange(Checked As Boolean)
    Select Tgl1.Checked
        Case True
            LblEasrLat.Text = "Latitude"
            LblLongNoth.Text = "Longitude"
            EastTxt.Text = Lat1
            NorthTxt.Text = Long1
        Case False
            LblEastLat.Text = "Eastings"
            LblLongNoth.Text = "Northings"
            EastTxt.Text = East
            NorthTxt.Text = North
    End Select
End Sub

And this is the code for the updating of the Edit-texts for the GPS:

B4X:
Sub GPS_LocationChanged (Location1 As Location)
    Lat1 = Location1.Latitude
    Long1 = Location1.Longitude
    Altitude = Location1.Altitude
    Dim str As String
    Dim digits As Int
    Dim sep As String
    OSGB.WGS84toOSGB36(Lat1, Long1, Altitude)
    str = OSGB.OSGB36toNGR(OSGB.NewLatitude, OSGB.NewLongitude)
    digits = 5   
    sep = " "
    ngr = "GridRef: " & str.SubString2(0, 2) & sep & str.SubString2(2, digits + 2)
    ngr = ngr & sep & str.SubString2(7, digits + 7) & CRLF
    If Local = "English (United Kingdom)" Then
        East = NumberFormat2(OSGB.Easting, 1, 0, 0, False)
        North = NumberFormat2(OSGB.Northing, 1, 0, 0, False)
        ngr = ngr & "National Grid: " & East & " " & North & CRLF
    Else
        East = 0
        North = 0
        EastTxt.Text = Lat1
        NorthTxt.Text = Long1
        Tgl1.Checked = True
        Tgl1.Enabled = False
    End If
    Select Tgl1.Checked       
        Case True
            EastTxt.Text = Lat1
            NorthTxt.Text = Long1
        Case False
            EastTxt.Text = East
            NorthTxt.Text = North
    End Select
           
            EastTxt.Invalidate
            NorthTxt.Invalidate
End Sub

Can I PM you the full project as I have encryption used in other projects I don't want to release in the public domain?
 
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
I've found a problem with the toggle button which is causing this issue. Even though the CheckedChnged event is raised when I press the button the checked value always returns FALSE.

In other words, the toggle button is not toggling for some reason.

Anyone else come across this?
 
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
Klaus,

The code is above, posted earlier within this thread although I've changed it to the following:

B4X:
Sub Tgl1_CheckedChange(Checked As Boolean)
    If Tgl1.Checked Then
            LblEastLat.Text = "Latitude"
            LblLongNorth.Text = "Longitude"
            EastTxt.Text = Lat1
            NorthTxt.Text = Long1
    Else
            LblEastLat.Text = "Eastings"
            LblLongNorth.Text = "Northings"
            EastTxt.Text = East
            NorthTxt.Text = North
    End If
End Su


and yes a breakpoint was set.

I have two togglebuttons and one is functioning correctly and I can see the state change. However, the other one is not changing state when its CheckedChanged event is raised.
 
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
Many thanks Klaus

I will implement your suggestion but I've managed to get it working again.

It was an old app and I'd reused the code and layouts and there is something going on either with the Tabhost or Tabhost extras.

I systemically quoted out lines in Activity_Create as each layout was loaded and the togglebutton eventually started to work correctly.

I need to look deeper into it

EDIT - I've found the error. There were two instances of the same togglebutton
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…