title: Adding new widget controls dynamically to an existing layout
body: <p>i've seen this question added on the stack but the information hasn't been helpful or successful yet, so i remain quite not sure.</p>
  
  <p>The gist of what I'm trying to do: <br/>
  I have a layout defined in xml, some_details_view.xml for example.<br/></p>
  
  <pre><code>setContentView(R.layout.some_details_view);
  </code></pre>
  
  <p>It has a bunch of text views laid out using a parent relative layout, a linear header layout, a linear footer layout, a middle scroll layout that contains a relative layout that hold some label - value type of text views.
  And at the bottom of the scroll view relative layout, I currently placed a frame layout as a place holder.</p>
  
  <p>On create of the corresponding activity, I set text in respective text views with data handed over from previous activity; basic stuff. <br/></p>
  
  <pre><code>&lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@color/white" &gt;
  
      &lt;LinearLayout
          android:id="@+id/header"
  
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true" &gt;
  
                          ...some header content
  
      &lt;/LinearLayout&gt;         
  
      &lt;LinearLayout
          android:id="@+id/footer"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:orientation="vertical" &gt;
  
          ..some footer content
  
      &lt;/LinearLayout&gt;
  
      &lt;ScrollView
          android:id="@+id/scroll"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_above="@+id/footer"
          android:layout_below="@+id/header"
          android:layout_margin="5dip" &gt;
  
  
          &lt;RelativeLayout
              android:layout_width="fill_parent"
              android:id="@+id/relativeScroll"
              android:layout_height="wrap_content" &gt;
  
              ...text views in relative layout
  
              &lt;FrameLayout
                  android:id="@+id/placeholder"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:layout_below="@+id/moreInfoValue" /&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/ScrollView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>After setting up text views for the given data, I use an async task to get some additional data that I want to show as a history list type of thing at the bottom of the static form layout. There could be 0 or more items so I either add 1 or more text views or none at all.</p>
  
  <p>In the post execute, which I understand to run on the main UI thread, I try to find an exiting container Layout/view group and add either a new Linear Layout to which I add new text Views, or just add the new text views directly to the existing container layout.</p>
  
  <p>here's the latest thing I tried:</p>
  
  <pre><code>ViewGroup mContainer = null; //defined as member variable of activity class and instatiated in on create
  mContainer = (ViewGroup)findViewById(R.id.placeholder); //set in on create
  LinearLayout ll = new LinearLayout(context); //on post execute of async task
  ll.setOrientation(LinearLayout.VERTICAL);
  mContainer.addView(ll); //add a new linear layout to an existing container layout
  //add some new text view widgets items dynamically
  for(NewDisplayItem item : items)
  {
      TextView tv = new TextView(context);
      tv.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
      tv.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
      tv.setText(item.getSomeText());
      ll.addView(tv); //add text view to new linear layout
  }
  </code></pre>
  
  <p>When the UI loads I don't see new items added to my layout after stepping through and watching the controls get added using the code above.</p>
  
  <p>Not sure what it is but something doesn't seem right about this approach in addition to the fact that it's not working. When the activity loads up, all the static views are setup and in view. I pop up a loading dialog, step through the async task stuff and I guess expect to see the dynamic controls add to the layout one by one?</p>