Call removeView() on the child's parent first?

Solution: ((ViewGroup)scrollChildLayout.getParent()). RemoveView(scrollChildLayout); //scrollView. RemoveView(scrollChildLayout) Use the child element to get a reference to the parent.

Cast the parent to a ViewGroup so that you get access to the removeView method and use that Thanks to @Dongshengcn for the solution.

Solution: ((ViewGroup)scrollChildLayout.getParent()). RemoveView(scrollChildLayout); //scrollView. RemoveView(scrollChildLayout); Use the child element to get a reference to the parent.

Cast the parent to a ViewGroup so that you get access to the removeView method and use that. Thanks to @Dongshengcn for the solution.

Scrollview. RemoveView(scrollChildLayout) Or remove all the child from the parent view, and add them again.Scrollview.removeAllViews().

I am already calling removeView in the code in my question above. RemoveAllViews() doesn't work either. – kasgoku Jun 29 at 21:16 Are you sure it is the parent you are calling removeView()/removeAllViews()?

I am doing very similar thing, and it has been working for me. – Dongshengcn Jun 30 at 13:47 1 You can look at its parent by looking at: view.getParent() developer.android. Com/reference/android/view/…() – Dongshengcn Jun 30 at 13:49.

All you have to do is post() a Runnable that does the addView().

Didn't work. This is what I tried: scrollView. RemoveView(scrollChildLayout); scrollView.

SetVisibility(View. GONE); parentLayout. Post(new Runnable() { @Override public void run() { parentLayout.

AddView(scrollChildLayout); } }); – kasgoku Jun 29 at 21:38.

The simplest solution here is to something like this: scrollView. RemoveView(scrollChildLayout); scrollChildLayout = new ScrollChildLayout(); parentLayout. AddView(scrollChildLayout); If you can't do that, I would suggest following Romain Guy's advice and posting a runnable.In case you haven't seen that sort of thing before, it looks something like this in your activity: private Handler handler; @Override public void onCreate(Bundle savedInstanceState) { super.

OnCreate(savedInstanceState); handler = new Handler(); } Then, wherever you wish to do the view juggling, you can do this: handler. Post(new Runnable(){ scrollView. RemoveView(scrollChildLayout); parentLayout.

AddView(scrollChildLayout); }).

I like the idea behind synchronized but it didn't help. Looking through the Android source, it looks like both removeView and addView call requestLayout, which "schedules" layout redrawing. It sounds like an asynchronous call.

The layout hasn't been redrawn after the first removeView when we get to the addView and it complains about the child element already having a parent. This was further supported by waiting on a breakpoint in between the two calls. When I did that, I did not get the exception.

– kasgoku Jun 29 at 21:19 tried the handler(just like your example)... same thing. – kasgoku Jun 29 at 21:48.

Android tabs The specified child already has a parent. Help to resolve exception “The specified child already has a parent. Android TableLayout - “The specified child already has a parent.

IllegalStateException: The specified child already has a parent. Android scrollview can't be created programmatically. Android: The specified child already has a parent.

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

Android - The specified child already has a parent. The specified child already has a parent. IllegalStateException: The specified child already has a parent.

Android: Notify Scrollview that it's child's size has changed: how? How to mantain aspect ratio of elements while rotating a ScrollView? How to solve for viewpager : The specified child already has a parent.

Getting an error “The specified child already has a parent. You must call removeView() on the child's parent first.”? The specified child already has a parent.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions