I like to know how can i clone a view object which is already there in the view hierarchy, so that it can be added to the same view hierarchy again.
views:
162answers:
1
+1
A:
When using an xml layout you can define your view in another layout and use the directive to put it in several places multiple times.
Soulreaper
2010-02-28 09:15:40
I suspect Mr. Reaper meant "use the `<include>` directive" -- XML tags get eaten unless formatted as source code. You can also manually inflate such layouts using `getLayoutInflater()` and add them to a `ViewGroup`. What you cannot do is clone an existing in-Java view hiearchy -- at least, there does not appear to be any built-in code to do that.
CommonsWare
2010-02-28 13:29:34
Well i am new this Android API, so dont know this <include> directive but the `cannot do` is true... as i tried doing the same, i got runtime error
Amit
2010-03-02 04:56:58
So, is there any way to clone a view from a view hierarchy already inflated at runtime, and use it elsewhere...
Amit
2010-03-02 05:15:33
yeah sorry the include tag has been swallowed by the syntax formatter.
Soulreaper
2010-03-02 16:23:59