Change label values on panels...on a Scrollview

DevBaby

Active Member
Licensed User
Longtime User
I created 8 panels that contains 6 labels each. I then added these panels to a scrollview (scrollview1). However I am not able to go back and change the value of the labels on the panels that I added to the scrollview.

I have tagged the panels and labels so that I can identify them later in code.

Using a 2 Panel with 2 label example, I believe that I am able to access the scrollview's panels and labels using...

Dim P as Panel
Dim L as label

P.Initialize("")
L.Initialize("")

P = scrollview1.Panel.GetView(0)
L = p.Getview(0)
L.Text = "New text0"

P = scrollview1.Panel.GetView(0)
L = p.Getview(1)
L.Text = "New text1"

P = scrollview1.Panel.GetView(1)
L = p.Getview(0)
L.Text = "New text0"

P = scrollview1.Panel.GetView(1)
L = p.Getview(1)
L.Text = "New text1"

The above does not work for me. Any ideas? Thanks in advance.
 

klaus

Expert
Licensed User
Longtime User
Unfortunately you don't give enough information.
- What is not working
- Do you get a message error, if yes what message
- How do you populate the ScrollView
etc.

Couldn't you post your test project as a zip file ?

Best regards.
 
Upvote 0

DevBaby

Active Member
Licensed User
Longtime User
I aologize, there is no error message. The label values never update to the new values.

Once I place the panels (with labels) on the scrollview, I am no longer able to update the label values.

Is there a way to change the label.text values? The code above is an example of what I used.
 
Upvote 0

DevBaby

Active Member
Licensed User
Longtime User
Below is the code I use to populate the scrollview. Page3Scroll1 is a layout (made in the designer) with 6 label type views.

Dim P As Panel
P.Initialize("")
P.Tag = "Metal"
P.LoadLayout("Page3Scroll1")
scrollview1.Panel.AddView(P, 0 , 0, scrollview1.Panel.Width, 60)
 
Upvote 0

Kimmowich

Member
Licensed User
Longtime User
Hey

When you create the 8 panels (from the one you made in the designer), you need to generate the members for that panel. Those 6 "dim Label1 - 6" needs to be placed inside the loop where you setup the 8 panels.. like this.

First create something to hold the panel and labels

Type tLabelInPanel (Pl As Panel, lb(6) As label)

Since you use Key-names for the panels, you could use a Map to hold the reference.

Dim HoldLabel As Map
HoldLabel.Initialize

B4X:
For i = 0 To 7 Do
   Dim Panel1 As Panel
   Dim label1 As Label
   Dim label2 As Label
   ect.
   ..
   create the Panel in ScrollView
   ..
   Panel1.tag = "Metal"
   
   Dim LabelList As tLabelInPanel
   LabelList.Initialize
   LabelList.Pl = Panel1
   LabelList.lb(0) = label1
   LabelList.lb(1) = label2
   ect.
   
   HoldLabel.add("Metal", LabelList)
Next

Now you have full access to all panels and their labels.

Dim Ref as tLabelInPanel

Ref = HoldLabel.get("Metal")
Ref.lb(3).text = "Changed"
Ref.Pl.Color = Colors.Red

This is one way of doing it.. Hope this helps a little.. :)

Sincerely
 
Upvote 0
Top