wierd issue (hiding/unhiding a label)

dougc

Member
Licensed User
Longtime User
hey all,
I am struggling with something that should be trivial ........

in designer I added two labels (Label7 and Label8) set visible to False and the text value to a colon )

I then used the designer script to get them positioned correctly and generated the members.

In my program have have logic that will make the labels invisible/visible depending on a button. So far so good, the issue is that the other labels 1-6 show and hide just fine when the button is pressed but label 7 and 8 do not.

The only difference is that the text for label 7/8 were defined in designer and the others are defined in code (don't see how that could make a difference but .....)

I am lost as to why this is happening, any advice/suggestions welcomed

thanks

dougc
:BangHead:
 

mc73

Well-Known Member
Licensed User
Longtime User
Check if you initialize these two labels in code. If so, remove the initialization process.
 
Upvote 0

dougc

Member
Licensed User
Longtime User
wierd issue with hiding/unhiding a label

sorry project is attached
 

Attachments

  • binaryclock.zip
    33.3 KB · Views: 211
Upvote 0

klaus

Expert
Licensed User
Longtime User
Have a look at the Button2_Click routine.
You change the Visible property of Label1 to Label6 but not for Label7 and Label8 !
The Visible property of Label7 and Label8 is not set to False in the Designer.

You have duplicate code in Activity_Create and Activity_Resume.
Loading layouts should be in Activity_Create no need to repeat it in Activity_Resume same for the Timer.

Best regards.
 
Upvote 0

dougc

Member
Licensed User
Longtime User
dang sorry about that I should of noticed that thank you very much and sorry for asking a question about something that I should of noticed

dougc
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should also change the Activity_Create routine like below:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If Activity.Width > Activity.Height Then
        Activity.LoadLayout("pmainview")
    Else
        Activity.LoadLayout("mainview")
    End If

    RadioButton2.Checked = True

    If RadioButton2.Checked = True Then
        showMilitary = 1
    Else
        showMilitary = 0
    End If
End Sub
You must remove the two RadioButton.Initialize lines.
In your code the RadioButton events are never fired.
You cannot use a view defined in a layout file before you have loaded it!

Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…