3

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

Mark
  • 315
  • 1
  • 5
  • 8

2 Answers2

3

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 ?

Plumillon Forge
  • 1,659
  • 1
  • 16
  • 31
1

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

Armin
  • 599
  • 2
  • 8
  • 19