title: How to add to the layout compound component programmatically Android?
body: <p>I created a compound  component <code>Box</code> which I want to add to the layout. <code>Box</code> xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/linearLayoutForBlock"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical"&gt;
      &lt;LinearLayout
          android:id="@+id/linearLayout1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="vertical" android:background="@drawable/screen_background" android:layout_marginLeft="5dp" android:layout_marginTop="5dp"&gt;
          &lt;ImageButton
              android:id="@+id/imageButtonContent"
              android:layout_width="50dp"
              android:layout_height="50dp"
              android:layout_gravity="center_horizontal"
              android:scaleType="fitCenter"
              android:src="@drawable/beach_bed" android:background="@drawable/buttonbackground" android:clickable="true" android:layout_margin="5dp" android:contentDescription="@string/sample_text"/&gt;
          &lt;TextView
              android:id="@+id/textViewContent"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:text="@string/sample_text"
              android:textColor="@color/deep_blue" android:layout_margin="5dp"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/merge&gt;
  </code></pre>
  
  <p><code>Box</code> class:</p>
  
  <pre><code>public class Box extends LinearLayout  {
  
      private TextView textContent;
      private ImageView imageContent;
  
      public Box(Context context, AttributeSet attrs) {
          super(context, attrs);
          ((Activity)getContext()).getLayoutInflater().inflate(R.layout.box, this);
          setupViewItems();
      }
  
      private void setupViewItems() {
          textContent = (TextView) findViewById(R.id.textViewContent);
          imageContent = (ImageView) findViewById(R.id.imageButtonContent);
      }
  
      public void setTextContent(String text) {
          this.textContent.setText(text);
      }
      public void setImageContent(String tag) {
          this.imageContent.setContentDescription(tag);
      }
  }
  </code></pre>
  
  <p>Everything works if I add the <code>Box</code> to the main xml file like:</p>
  
  <pre><code>&lt;com.mypackage.alexey.Box
  android:id="@+id/mybox"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  /&gt; 
  </code></pre>
  
  <p>The problem is that I'd like to create many of boxes programmatically something like this: <code>Box mybox= new Box();</code>. How to do it?</p>