Android Question AHPageContainer and AHViewPager Help


Licensed User
I need some advise please about the following.

1. I have a pagecontainer in my activity, there are 3 variable pages i.e. panels that can be added on each page. On the attached image this is A, scrollable from left to right
2. For instances where the pages are the same, in each page there is a panel that I want to add a new pagecontainer when B is clicked
3. The panel to have another pagecontainer is C, the pagecontainer is D
4. Inside each D page there is a panel with some controls, lets call this E, a couple of Es scrolling from left to right

Now, I'm able to make this work for one page A, when I click B, items get loaded and I'm able to scroll the items inside D whilst i'm still inside a single A page. No matter how many times I click on B, the items are reloaded in D and all is perfect.

The issue now is when I scroll to another A page and perform the same process of clicking B.

When I scroll A and execute the same process on another page, I get an error on the .AddPage method of D. This is the code that runs when B is clicked on each page

' get the details of this page
    Dim pg As Panel = container.GetPageObject(CurrentPage)
    media_id = pg.Tag
    ' get the sub-panel in this page
    Dim subPG As Panel = GetPanelByTag("pnllikes" & media_id)
    subPG.Visible = True
    ' initialize the subcontainer
    subPager.Initialize(subContainer, "SubPager" & media_id)
    'Now we can add the pager to the panel

Then I run

subContainer.AddPage(pg, media_like_id)

where pg is a panel i create with controls, now on the second A page, this .AddPage methods results in an error

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

I'm not even sure which panel its referring to. Is there a quicker way of perhaps for me to identify my problem? or its not possible to have multiple pagers in one activity?


  • error.png
    10.2 KB · Views: 295