Tuesday, 3 September 2013

Recycling an inflated view on Android

Recycling an inflated view on Android

I have a complicated ViewGroup for a fragment which is created every now
and then. Only 1 instance fragment can be shown at a time.
I was wondering if it is possible to somehow store the inflated view and
just reuse it when the fragment is created again.
Obviously the view properties will have to be changed, but at least the
view will not need to be inflated again.
I tried simply to store the view element as a static element and then
check if it exists, and if does, use it.
However, I believe the View element has some fragment specific properties
and if you use it with a fragment which has a different reference id, it
will fail - well..it failed.
Has anyone tried to cache inflated views and reuse them?

No comments:

Post a Comment