title: android: add view to an inflated View
body: <p>I want to inflate a layout from my res/layout directory, and add some views to it in my activity class.</p>
  
  <p>My layout xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_marginTop="30dip"
      android:layout_height="fill_parent" &gt;
  
      &lt;Button
          android:id="@+id/reg_button"
          style="@style/simple_button"
          android:onClick="clickButton"
          android:text="@string/reg_button" /&gt;
  
  
      &lt;!--  I WANT TO PUT CONTENT HERE ! --&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In my java code, I try to inflate the above layout and add a linearLayout with a Button.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      mContext = getApplicationContext();
  
      //inflate xml
      LinearLayout mainLayout = (LinearLayout)     LayoutInflater.from(getBaseContext()).inflate(R.layout.regions_search, null);
  
  
      //Create a new LinearLayout
      LinearLayout newLinear = new LinearLayout(mContext);        
      newLinear.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  
      //create  a new Button
      Button test = new Button(mContext);
      test.setText("My button");
  
      //first , I add button to the LinearLayout
      newLinear.addView(test);
  
      //Then, I add layout to the inflated layout
      mainLayout.addView(newLinear);
  
  
      //display
      setContentView(mainLayout);
  </code></pre>
  
  <p>But the newLinear view (and its children) aren't getting displayed.</p>