我如何克隆一个视图?视图

2023-09-12 03:33:34 作者:二是一种笵er

我的问题是几乎完全这样一个问题:

My question is almost exactly this question:

克隆的TextView将其追加到的ViewGroup

不过,我在不断膨胀的视图,然后试图复制其在性能方面的原因对象级别(我不想来解析XML每一次),这样的回答并不能帮助我。 View.clone()是受保护的,它显然不具有复制构造。有没有办法做到这一点?

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?

推荐答案

您无法克隆的观点,要做到这一点是吹你查看每一次。注意,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.