Views of an activity

ukimiku

Active Member
Licensed User
Longtime User
How can one programmatically determine which views an activity has and of which type each of the views is?

Pseudo-code:
B4X:
for n = 1 to Activity.NumberOfViews
   v = Activity.View(i)
   t = TypeOf(v)
   if t = Activity.Types.ImageView then ...
next

Thank you.

Regards,
 

derez

Expert
Licensed User
Longtime User
B4X:
for n = 0 to Activity.NumberOfViews -1
 Dim v as view
v= activity.getview(n)  
if v is panel then
   dim p as panel
   p = v
...
else if v is button then
...
else
...

end if
next
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
B4X:
For i=0 To Activity.NumberOfViews - 1
    Dim v As View
    v = Activity.GetView(i) 

    If v Is EditText Then
    Else If v Is Label Then
    Else If v Is AutoCompleteEditText Then
    End If
Next

That is the simplest way I think.

Regards, Ricky
 
Upvote 0

ukimiku

Active Member
Licensed User
Longtime User
Thank you both for your code. Now I can cycle through the views and determine if they have to be moved. Thanks.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…