Friday, 9 August 2013

Android: Programmatically getting layout params and copying views

Android: Programmatically getting layout params and copying views

Say you have a TextView that you made in an xml file. I am wondering if it
is possible to copy this view's Layout Parameters programmatically instead
of having to programmatically write them all out again. Or if you could
just create a new TextView and make it the same as the original one and
then attach it to a new view that will be added.
I tried the latter and ran into the error that said:
08-09 22:04:55.253: E/AndroidRuntime(1848): Caused by:
java.lang.IllegalStateException: The specified child already has a parent.
You must call removeView() on the child's parent first.
But this error would persist even after I had tried removing them from the
initial view. Any ideas? Or is this just completely unfeasible and dumb.

No comments:

Post a Comment