How to cache views in Android?
<p>I'm building an app which generate some labels and views dynamically. 
 I defined how my "custom view" should look in a xml layout and from code I inflate this layout. </p>

<p>Because the inflated layout will be always the same, I want to make this step just one time. 
 After I have the layout, I want to cache it and use it next time when I will need it.</p>

<p>The problem is that if I put my inflated layout in cache (in a hashmap by example) and add it to a parent layout, next time when I try to add it again (this time I will get the layout from cache) the system says that my layout already have a parent. </p>

<p>Do you know any method to detach a child view from parent without removing the child view?</p>

<p>Added some code:</p>

<pre><code>    private static HashMap&lt;String, LinearLayout&gt; mComponentsCache;

// inflate and add the layout in cache
layout = (LinearLayout)mLf.inflate(R.layout.form_textbox, mHolder, false);
mComponentsCache.put(FormFieldType.TYPE_TEXT, layout);
</code></pre>
