How do I clone a View?

余生长醉 提交于 2019-12-17 05:05:13

问题


My question is almost exactly this question:

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?


回答1:


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.



来源:https://stackoverflow.com/questions/4159211/how-do-i-clone-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!