Android Question Copy the views of a panel of a HorizontalScrollView to another external panel.

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I am trying to copy all the views that a HorizontalScrollView panel has to another panel, but it always shows the following error:

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

The code, summarized, that I am using is this:
B4X:
pnTrastear.RemoveAllViews

For Each vv As View In hsvMGCanvas.Panel.GetAllViewsRecursive
  If vv Is Label Then
    Dim lb As Label = vv
    pnTrastear.AddView(lb, vv.Left,vv.Top,vv.Width,vv.Height)
  End If
Next
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, you mean something like:
B4X:
pnTrastear.RemoveAllViews

For Each vv As View In hsvMGCanvas.Panel.GetAllViewsRecursive
  If vv Is Label Then
    Dim lb As Label = vv
    Dim lbNew As Label
    lbNew.Inicialize("")
    lbNew.Text=lb.Text
    ...
    pnTrastear.AddView(lbNew, vv.Left,vv.Top,vv.Width,vv.Height)
  End If
Next
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As this thread is related to this thread, why do you want to copy views from one panel to another one ?
I am interested to understand what the program is supposed to do with same or similar views on two different panels.
In my mind you could use the HorizontalScrollView for all different user actions.
Could you please explain how the program is supposed to work.
It is easier to give concrete advice when we know the whole problem not just answering a specific question.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I created this thread on post #5 of the other thread, in which you have helped me.
I was quite lost at the time and trying different things.
This thread can be deleted (or mixed with the previous one).
Thank you very much, friends.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…