title: Programmatically include layout in Android (replicating the <include/> tag
body: <p>I have multiple skeleton layouts like this: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"
         ...
  &lt;/merge&gt;
  </code></pre>
  
  <p>I need to wrap this layout in a LinearLayout, but don't want to make multiple xml files since they'd just have a linearlayout and an include tag, like this...</p>
  
  <pre><code>&lt;LinearLayout    
      &lt;include layout="@layout/layout1"
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Is there any way I can achieve the same effect as that @layout/layout1 programmatically? Like choose which layout to include? I'm inflating this layout for a ViewHolder in a recyclerview, and right now I'm doing this.</p>
  
  <pre><code>@Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      ViewHolder vh = null;
      View inflatedView;
      LayoutInflater inflater = LayoutInflater.from(parent.getContext());
  
      switch (x) {
          case 1:
              inflatedView = inflater.inflate(R.layout.cool_layout, parent, false);
              inflater.inflate(R.layout.layout1, (LinearLayout)inflatedView, true);
              vh = new ViewHolder(inflatedView);
          case 2:
              inflatedView = inflater.inflate(R.layout.cool_layout, parent, false);
              inflater.inflate(R.layout.layout2, (LinearLayout)inflatedView, true);
              vh = new ViewHolder(inflatedView);
  </code></pre>
  
  <p>It makes two inflate() calls which probably isn't a good idea, so I'm looking for an alternative aside from making a bunch of xml files.</p>