AHViewPager Delete all pages?

Scantech

Well-Known Member
Licensed User
Longtime User
How do you delete all of the pages?

B4X:
        Dim x, size As Int
   size = Container.Count -1
   
   For x = 0 To size
      Container.DeletePage(x)
      Tabs.NotifyDataChange
   Next

I added 4 pages and it gives me an error saying the size is 2? I want to delete all of them at once. Thanks
 

wl

Well-Known Member
Licensed User
Longtime User
I'm not fully aware of how the pages are working, but in general when remove items from a list you should work backwards, this is:

from the last item (size - 1) to the first (index = 0), because

By deleting the first item (index = 0), the second will become the new first (and get index = 0 as well) etc ..
 
Upvote 0

hbruno

Member
Licensed User
Longtime User
or :
For x = size To 0 step -1
Container.DeletePage(x)
Next
Tabs.NotifyDataChange

so, you delete Page(3) -> Page(2) -> Page(1) -> Page(0)
 
Upvote 0
Top