如何克隆视图?

发布于 2024-10-02 04:15:12 字数 289 浏览 1 评论 0原文

我的问题几乎就是这个问题:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪荡不羁 2024-10-09 04:15:12

您无法克隆视图,方法是每次都膨胀您的视图。请注意,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文