Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Clone of a View in Android

Is there any way that a View can be cloned in Android? I have a reference to a complicated view which was first inflated from a layout, and then throughout the lifetime of the app was programatically edited, adding subviews, removing views etc.

I need some way to clone this view object. At this point in time in the app, there isn't enough information available for me to re-inflate the layout and apply all of the view modifications to it programatically to get it to match the original view.

Thanks in advance

like image 936
Mark Avatar asked Nov 25 '25 19:11

Mark


2 Answers

Views can't be cloned

I think you have to implement it by yourself (constructor or method)

Can you think about another solution ? Maybe retaining the View state in another object ?

What is your case which require such a clone ?

like image 160
Plumillon Forge Avatar answered Nov 28 '25 09:11

Plumillon Forge


You can't clone views, you have to inflate your view.

like image 39
Armin Avatar answered Nov 28 '25 07:11

Armin