如何克隆视图?
我的问题几乎就是这个问题:
Clone textview to append it to a ViewGroup
但是,我正在膨胀一个视图,然后出于性能原因尝试在对象级别克隆它(我不想每次都解析 XML),所以这个答案对我没有帮助。 View.clone() 受到保护,并且它显然没有复制构造函数。有什么办法可以做到这一点吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法克隆视图,方法是每次都膨胀您的视图。请注意,XML 被编译为二进制文件,可以非常有效地进行解析。
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.