I am creating an application that generates some labels and views dynamically. I determined how my “custom view” should look in the xml layout and from the code I inflate this layout.
Since the bloated layout will always be the same, I want to take this step only once. After I have the layout, I want to cache it and use it the next time I need it.
The problem is that if I put my bloated layout in the cache (in the hash file for example) and add it to the parent layout, the next time I try to add it again (this time I get the layout from the cache) the system says that my layout already has a parent.
Do you know any method to detach a child view from a parent without deleting the child view?
Added code:
private static HashMap<String, LinearLayout> mComponentsCache;
layout = (LinearLayout)mLf.inflate(R.layout.form_textbox, mHolder, false);
mComponentsCache.put(FormFieldType.TYPE_TEXT, layout);
source
share