Android Question Unable to change contents label view

albert1963

Member
Licensed User
Longtime User
My problem is that I can't set the text of some labels programmatically. Refer to attach project file.

The following code change the Label text values:

B4X:
    Sub CheckPart6Tab() As Boolean

        Select Case SpinAantalBruggen.SelectedIndex
            Case 0
                'Only single bridge
                BtnPreviousSetBridges.Visible = False
                BtnNextSetBridges.Visible = False
                ShowBridge2Items(False)
                ShowBridge3Items(False)
                ShowBridge4Items(False)
                LblBrugAHeader.Text = "Brug A of X"
                LblBrugBHeader.Text = ""
                LblBrugCHeader.Text = ""
                LblBrugDHeader.Text = ""
            Case 1
                'Double bridge AB or XY
                BtnPreviousSetBridges.Visible = False
                BtnNextSetBridges.Visible = False
                ShowBridge2Items(True)
                ShowBridge3Items(False)
                ShowBridge4Items(False)
                LblBrugAHeader.Text = "Brug A of X"
                LblBrugBHeader.Text = "Brug B of Y"
                LblBrugCHeader.Text = ""
                LblBrugDHeader.Text = ""
            Case 2
                'Quadruple bridge XA, XB, YA, YB
                BtnPreviousSetBridges.Visible = True
                BtnNextSetBridges.Visible = True
                ShowBridge2Items(True)
                ShowBridge3Items(True)
                ShowBridge4Items(True)
                LblBrugAHeader.Text = "Brug XA"
                LblBrugBHeader.Text = "Brug XB"
                LblBrugCHeader.Text = "Brug YA"
                LblBrugDHeader.Text = "Brug YB"
            Case Else
                BtnPreviousSetBridges.Visible = False
                BtnNextSetBridges.Visible = False
                ShowBridge2Items(False)
                ShowBridge3Items(False)
                ShowBridge4Items(False)
                LblBrugAHeader.Text = "Brug A of X"
                LblBrugBHeader.Text = ""
                LblBrugCHeader.Text = ""
                LblBrugDHeader.Text = ""
        End Select
       
    End Sub

But when debugging the code the code is really executed but the text of the 4 mentioned labels remain unchanged.

The CheckPart6Tab functions is called when a certain timer is finished (twice each second):

B4X:
    Sub CheckPart6RequirementsTimer_Tick

        CheckPart6Tab
        CheckPart6BridgeARelatedItems
        CheckPart6BridgeBRelatedItems
       
    End Sub

This timer is created en initialized using the InitialiseTimers function called in the Activity_Create.

Any help/suggestion appreciated?
 

Attachments

  • MyExample.zip
    81.4 KB · Views: 179

albert1963

Member
Licensed User
Longtime User
Sorry but it is a bit too much to go over a 8000 lines activity and try to understand it...

Make sure that you aren't initializing the labels multiple times.


Thanks for the quick reply and I'm aware of the complexity of this project to understand it in a short amount of time.
These labels are all defined using the Designer and used in different Tabpages. The fact that these labels in the different tabpages have all the same name, could that be my problem of multiple initializing?
 
Upvote 0

albert1963

Member
Licensed User
Longtime User
Yes, it can be the cause of this problem.

If for example you have two layout files with Label1. The 'Label1' variable will reference the label from the last loaded file.


Thanks for the explanation and the help. I assume that the same applies to other view types like buttons, etc
 
Upvote 0
Top