Search code examples
basic4android

How to programmatically access views?


I have a lot of views. And I like to have them placed in the program, taking the size of the screen in account. But I have a problem accessing the views in a loop.

Now, I have to take one view at the time:

view1.top = xdip
view2.top = xdip

What I really want to do is:

for c = 1 to 40
    view(c).top = ...
next

But I can't get it to work. Can anyone enlighten me?


Solution

  • See this tutorial.

    Here is an example:

    For i = 0 To Activity.NumberOfViews - 1
        Dim v As View
        v = Activity.GetView(i)
        v.Top = 30dip
    Next