title: How to remove old content and show new content when using LayoutInflater in my case?
body: <p>My <strong>main.xml</strong> layout simply contains <strong>two buttons</strong> and a <strong>content area</strong>, which shows below:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
  
      &lt;LinearLayout 
          android:id="@+id/myBtns"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
      &gt;
          &lt;Button
              android:id="@+id/btn_one"
              android:layout_width="100dip"
              android:layout_height="30dip"
                  android:text="button one"
           /&gt;
           &lt;Button
              android:id="@+id/btn_two"
              android:layout_width="100dip"
              android:layout_height="30dip"
                  android:text="button two"
           /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout 
          android:id="@+id/content_area"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
      &gt;
           &lt;!--different button press will embed different content here--&gt;
  
      &lt;/LinearLayout&gt;
  
  
     &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I would like to create my own <strong>tab-like feature</strong> that each button press will update the content(the <code>content_area</code>) below the buttons. So I have prepared two other content layout:</p>
  
  <p><strong>content_one.xml</strong>:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
      &lt;TextView.../&gt;
      &lt;Button .../&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>content_two.xml</strong>:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
      &lt;Gallery.../&gt;
      &lt;Button .../&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>With all my simple codes showed above, I would like to implement the feature that:</p>
  
  <p>in <strong>main.xml</strong>:</p>
  
  <ul>
  <li><p>when <code>button_one</code> is pressed, <strong>content_one.xml</strong> will be embeded to the <code>content_area</code> of <strong>main.xml</strong>; </p></li>
  <li><p>when <code>button_two</code> is pressed, the <code>content_area</code> of <strong>main.xml</strong> will be updated to <strong>content_two.xml</strong></p></li>
  </ul>
  
  <p>Which means using button to create a <strong>tab-like feature</strong>.</p>
  
  <p>I tried:</p>
  
  <pre><code>button_one.setOnClickListener(new OnClickListener(){
          @Override
          public void onClick(View v){
              LayoutInflater inflater = (LayoutInflater)MyActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View inflatedView = inflater.inflate(R.layout.content_one, null);
  
              LinearLayout contentArea= (LinearLayout) findViewById(R.id.content_area);
              contentArea.addView(inflatedView);
          }
      });
  
  button_two.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v){
                  LayoutInflater inflater = (LayoutInflater)MyActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  View inflatedView = inflater.inflate(R.layout.content_two, null);
  
                  LinearLayout contentArea= (LinearLayout) findViewById(R.id.content_area);
                  contentArea.addView(inflatedView);
              }
          });
  </code></pre>
  
  <p>The above code is <strong>partly working</strong>, what I mean is that when <code>button_one</code> is pressed, the <code>content_area</code> shows <strong>content_one.xml</strong> , <strong>or</strong> when <code>button_two</code> is pressed, the <code>content_area</code> shows content_two.xml , they are working fine! </p>
  
  <p>But if either button is pressed firstly, then press the other one, the content remains in the old button triggered content. For example, when application first loaded, if firstly press <code>button_one</code>, <strong>content_one.xml</strong> is showing, after that , if I press <code>button_two</code>, the content is <strong>remain</strong> in <strong>content_one.xml</strong>.</p>
  
  <p>My Question is how to remove the old content and show the new content when using <strong>LayoutInflater</strong>?</p>