What are the advantages and disadvantages of creating a new view vs overwriting the same view all the time? Android

226 views Asked by At

I'm making an app and almost everything in it (The textboxes, menus, textviews) are created and shown programmatically.

When I have to show different content, I delete everything in the view and load the new textboxes, menus etc.

Is it better to create a new view each time?

1

There are 1 answers

1
Amit Vaghela On BEST ANSWER

Not, that much.

Overriding same view

You have to maintain visibility of all components

Is it better to create a new view each time?

If you can maintain all components than not needed otherwise you have to create.

AND

Found here ,Inflating view is very fast (almost as fast as creating views manually).

It might be surprising for you to hear but inflate in fact does not parse the XMLs at all. XMLs for layout are parsed and pre-processed at compile time - they are stored in a binary form which makes view inflation very efficient.