Android Question Scrollview and access to its views

slugger

Member
Licensed User
Longtime User
Hello,

I am using a Scrollview and dynamically add views to it using

panel1.addview(label1,.....and so on)
panel1.addview(label2,.....and so on)
panel1.addview(label3,.....and so on)
panel1.addview(label4,.....and so on)

Everything works fine and the scrollview works as expected.

Now, how can I modify the text or the width of, say, LABEL 2, at the 11th view?

I can't find any native method to gain access to a specific label inside a specific view which has been already programmatically added to the scrollview.

Any hints?

Thank you in advance.
 

klaus

Expert
Licensed User
Longtime User
With panel1.GetView(Index)
Index is the index of the view beginning with 0 and so on.
Every time you add a view the Index is incremented by 1.
In you case, change the text of Label4
B4X:
Dim lbl As Label
lbl = panel1.GetView(3)
lbl.Text = NewText
Best regards.
 
Upvote 0

slugger

Member
Licensed User
Longtime User
With panel1.GetView(Index)

Thank you Klaus but it's not exactly what I meant.

I already knew the panel Getview, what I need is a Scrollview Getview and the chance to navigate through it.

Take a look at this Erel's example:

http://www.b4x.com/android/forum/threads/list-with-two-columns-and-a-checkbox.7221/#post-41354

How can I change, for example, the text of the 4th label from

Value #4

to

NewValue #4

and all this *AFTER* all the views have been added to the scrollview panel?
 
Upvote 0

slugger

Member
Licensed User
Longtime User
Ok,

I found by myself.


B4X:
Dim panel0 As Panel
panel0=svPS.Panel
      For i=1 To panel0.NumberOfViews-1
        Dim lblTemp As Label
        Dim pnlTemp As Panel
        lblTemp.Initialize("")
        pnlTemp.Initialize("")
        pnlTemp=panel0.GetView(i)
        lblTemp=pnlTemp.GetView(1)
       If lblTemp.Text="Value #4" Then
           lblTemp.Text="NewValue #4"
       End If
      Next
 
Upvote 0
Top