S Scantech Well-Known Member Licensed User Longtime User Jan 25, 2012 #1 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
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
W wl Well-Known Member Licensed User Longtime User Jan 25, 2012 #2 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
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 ..
corwin42 Expert Licensed User Longtime User Jan 25, 2012 #3 Correct. The above code should work if you use Container.DeletePage(0) in your loop. Upvote 0
S Scantech Well-Known Member Licensed User Longtime User Jan 25, 2012 #4 Thank you Both. Container.DeletePage(0) did the job. Upvote 0
H hbruno Member Licensed User Longtime User Jan 25, 2012 #5 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
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)