Android Question How to access a CustomView object in b4xmainpage by view index?

Hi,
As an exercise for learning to create custom views, I have implemented a custom view class named TapCounter which is made of a panel and 2 labels. Then I added 3 views of this class in the designer. They work well, I think. But I don't know how to access an object of TapCounter by index from its parent in B4xmainpage.

By reading This thread, I understand that what ".getview()“gets in the context of custom view is not actually a view, but a base panel. The problem is I have no idea of how to access the parent of the base panel.

I tried the following code because I thought that if I could access the Activity, I could use a command like "activity. getview()". But it doesn't work.
my code:
'***In B4xMainPage:

private sub btn1_click
    Dim p As TapCounter=Root.Parent.As(Activity).GetView(0)' I don't know how to get access to the base panel of a Tapcounter object by index
end sub

So, how should I solve this? and thanks for any ideas or help
 

Attachments

  • Snipaste_2024-02-06_20-56-22.gif
    Snipaste_2024-02-06_20-56-22.gif
    158.7 KB · Views: 32
Top