How do I clone a View?

AndroidViewCopyClone

Android Problem Overview


My question is almost exactly this question:

https://stackoverflow.com/questions/3900044/clone-textview-to-append-it-to-a-viewgroup

However, I was inflating a view, and then attempting to clone it at the object level for performance reasons (I don't want to parse XML every single time), so that answer doesn't help me. View.clone() is protected and it apparently doesn't have a copy constructor. Is there any way to do this?

Android Solutions


Solution 1 - Android

You cannot clone views, the way to do it is to inflate your View every time. Note that the XML is compiled into binary which can be parsed very efficiently.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSapphireSunView Question on Stackoverflow
Solution 1 - AndroidRomain GuyView Answer on Stackoverflow