title: Inflate a layout into another layout (or convert the layout to a view and then inflate the view)
body: <p>I want to inflate a layout multiple times using a loop into another layout. the java is fine when i inflate a TextView or any other single view.  but i want to inflate this entire layout.   What method do i use for this because the following code wont work. (like i said, the loop and all is fine, its just i cant inflate an entire layout. I only know how to inflate a simple view).</p>
  
  <pre><code>View childInflatedView = (View) theInflater.inflate(R.id.restaurant_displayed_on_list, null);
  linLayout.addView(childInflatedView);
  </code></pre>
  
  
  
  <pre><code>&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="30dp"
  android:orientation="horizontal"
  android:background="@drawable/gradient_bg_hover"
  android:id="@+id/restaurant_displayed_on_list" &gt;
  
  &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="0dp"
      android:layout_weight="6"
      android:layout_height="fill_parent"
      android:text="this is the inflated text"
      android:textColor="#990099"
      android:textSize="20dp"
      android:gravity="center_horizontal"
  
      /&gt;
  
  &lt;Button    
  android:layout_width="0dp"
  android:layout_weight="1"
  android:layout_height="fill_parent"
  android:background= "@drawable/delete"
  /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Edit1:</strong></p>
  
  <p>As stated by Matthew, I think the solution is to inflate the layout by layout resource ID.
  The problem I think lies in this line of code not shown above since the layout cannot be cast to a TextView:</p>
  
  <pre><code>View categoryInflatedView1 = (View) theInflater.inflate(R.layout.categories_available, null);
  
  ((TextView) categoryInflatedView1).setText(category1);          
  
  linLayout.addView(categoryInflatedView1);
  </code></pre>
  
  <p>How do i access the TextView that lies inside of the layout. I need to edit the textview before inflating.</p>