title: Add multiple custom views to layout programmatically
body: <p>If I for example have empty layout like this:</p>
  <h3>layout1.xml</h3>
  <pre class="lang-xml prettyprint-override"><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;fill_parent&quot;
      android:orientation=&quot;vertical&quot; &gt;
   
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>And some other Layout like this:</p>
  <h3>layout2.xml</h3>
  <pre class="lang-xml prettyprint-override"><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;fill_parent&quot;
      android:orientation=&quot;horizontal&quot; &gt;
   
      &lt;TextView
          android:id=&quot;@+id/button1&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;TextView 1&quot; /&gt;
   
      &lt;Button
          android:id=&quot;@+id/button2&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Button 2&quot; /&gt;
   
      &lt;Button
          android:id=&quot;@+id/button3&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Button 3&quot; 
          android:layout_weight=&quot;1&quot;/&gt;
   
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>I would like to add <code>layout2.xml</code> to <code>layout1.xml</code> programmatically. I would need to have multiple different version <code>layout2.xml</code> which I would add when I want. Each one would have different text on <code>TextView</code> and <code>Button</code>s.</p>
  <p>In case of regular Android <code>View</code> I would usually do it similarly like this with <code>addView</code>:</p>
  <pre class="lang-java prettyprint-override"><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      TextView tv1 = new TextView(this);
      tv1.setText(&quot;HELLO&quot;);
      my_linear_layout.addView(tv1);
  
      Button btn2 = new Button(this);
      bt2.setText(&quot;WORLD&quot;);
      my_linear_layout.addView(btn2);
  }
  </code></pre>
  <p>How can I do it if I don't have something simple like <code>TextView</code> or <code>Button</code>, and if I have my own XML defined <code>View</code>?</p>
  <p>Would it be possible to somehow put all the views inside adapter like for a <code>ListView</code> and then get it when needed and just call <code>addView</code> on those <code>View</code>s?</p>