title: Inflate layout programmatically within another layout
body: <p>I need help with my android app. I need inflate a layout within another layout and I dont know how I do. My xml code is this:</p>
  
  <ul>
  <li><p>item.xml - I need inflate multiple xml (depending on a variable number)</p>
  
  <pre><code>    &lt;RelativeLayout
           android:id="@+id/cartel_N1"
           android:layout_width="150dp"
           android:layout_height="match_parent"
           android:background="@color/tabhost_background_pressed"
           android:layout_marginRight="22dp"
           android:orientation="vertical" &gt;
  
      &lt;ImageView 
          android:id="@+id/img_N1"
          android:layout_width="120dp"
          android:layout_height="120dp"
          android:layout_marginLeft="15dp"
          android:layout_marginTop="15dp"
          android:layout_marginRight="15dp"
          android:src="@drawable/mcdonalds_icon" /&gt;
  
      &lt;TextView 
          android:id="@+id/title_N1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:text="McDonals del CC Alcampo"
          android:layout_marginBottom="10dp"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:textSize="15sp" /&gt;
  
      &lt;TextView 
          android:id="@+id/categoria_N1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:text="CATEGORIA"
          android:textSize="16sp"
          android:textStyle="bold"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp" /&gt;
  
      &lt;RelativeLayout 
          android:id="@+id/stars_and_distance_N1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;ImageView
              android:id="@+id/stars_N1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@drawable/stars_25"
              android:layout_marginLeft="15dp"
              android:layout_marginTop="7dp" /&gt;
  
  
          &lt;TextView
              android:id="@+id/distance_N1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="200m"
              android:textSize="12sp"
              android:layout_alignParentRight="true"
              android:layout_marginRight="15dp"
              android:gravity="center_vertical"
              android:layout_marginTop="3dp" /&gt;
  
  
          &lt;ImageView
              android:id="@+id/icon_pos_N1"
              android:layout_width="10dp"
              android:layout_height="10dp"
              android:src="@drawable/marker_distance"
              android:layout_toLeftOf="@id/distance_N1"
              android:layout_marginTop="7dp" /&gt;
  
      &lt;/RelativeLayout&gt;&lt;LinearLayout
      android:id="@+id/cartel_N1"
      android:layout_width="150dp"
      android:layout_height="match_parent"
      android:background="@color/tabhost_background_pressed"
      android:layout_marginRight="22dp"
      android:orientation="vertical" &gt;
  
      &lt;ImageView 
          android:id="@+id/img_N1"
          android:layout_width="120dp"
          android:layout_height="120dp"
          android:layout_marginLeft="15dp"
          android:layout_marginTop="15dp"
          android:layout_marginRight="15dp"
          android:src="@drawable/mcdonalds_icon" /&gt;
  
      &lt;TextView 
          android:id="@+id/title_N1"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:text="McDonals del CC Alcampo"
          android:layout_marginBottom="10dp"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:textSize="15sp" /&gt;
  
      &lt;TextView 
          android:id="@+id/categoria_N1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center_horizontal"
          android:text="CATEGORIA"
          android:textSize="16sp"
          android:textStyle="bold"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp" /&gt;
  
      &lt;RelativeLayout 
          android:id="@+id/stars_and_distance_N1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;ImageView
              android:id="@+id/stars_N1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:src="@drawable/stars_25"
              android:layout_marginLeft="15dp"
              android:layout_marginTop="7dp" /&gt;
  
  
          &lt;TextView
              android:id="@+id/distance_N1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="200m"
              android:textSize="12sp"
              android:layout_alignParentRight="true"
              android:layout_marginRight="15dp"
              android:gravity="center_vertical"
              android:layout_marginTop="3dp" /&gt;
  
  
          &lt;ImageView
              android:id="@+id/icon_pos_N1"
              android:layout_width="10dp"
              android:layout_height="10dp"
              android:src="@drawable/marker_distance"
              android:layout_toLeftOf="@id/distance_N1"
              android:layout_marginTop="7dp" /&gt;
  
      &lt;/RelativeLayout&gt;
  </code></pre></li>
  <li><p>This is my main xml:</p>
  
  <pre><code>&lt;ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"&gt;
  
    &lt;LinearLayout
         android:id="@+id/container_destacado"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical" &gt;
  
             &lt;!-- Inflate multiple xml file here --&gt;
  
        &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre></li>
  </ul>