title: Adding TextViews at the end of an AsyncTask
body: <p>I need to add text to a ScrollableLayout after it's remotely retrieved from an <code>AsyncTask</code>. Since I don't know the number of strings involved, I need to programmatically create as many <code>TextView</code>s as needed.</p>
  
  <p>Layout code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/view_phone_mainView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;LinearLayout
          android:id="@+id/view_phone_linearLayout"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="top" &gt;
  
          &lt;TextView
              android:id="@+id/view_phone_lblTitle"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:gravity="center_horizontal|center_vertical"
              android:text="@string/view_phone_title"
              android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
          &lt;TextView
              android:id="@+id/view_phone_lblWarning"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/view_phone_warning"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:visibility="invisible" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>Activity</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          pDialog = new ProgressDialog(this);
          pDialog.setIndeterminate(true);
          pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          pDialog.setMessage(getString(R.string.view_phone_wait));
  
          pDialog.show();
  
          task = new MessageLoaderTask(); //Returns String[] on callback
          task.execute((Void) null);
      }
  
      public void onRulesLoaded(String[] messages) { //Directly called by OnPostExecute
          LinearLayout container = (LinearLayout) findViewById(R.id.view_phone_linearLayout);
          if (messages != null) {
  
              for (String m : messages) {
                  TextView tv = new TextView(this);
                  tv.setText(m);
                  tv.setTextAppearance(this, android.R.attr.textAppearanceSmall);
                  tv.setVisibility(View.VISIBLE);
                  tv.setBackgroundColor(Color.TRANSPARENT);
                  tv.setTextColor(Color.BLACK);
  
                  container.addView(tv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
              }
          }
  
          pDialog.dismiss();
      }
  </code></pre>
  
  <p><strong>I am sure</strong>, by debug, that strings are correctly valued. The result is that the title label gets displayed, the warning is hidden but below there is only white......</p>
  
  <p>I tried to scroll and noticed that the scrolling area is veeeeeeeeeery long, compatible with the long <code>Lorem ipsum</code> stub text I used for testing. If I truncate via debug one of the strings to empty (there are only 2) the scrollable area is shorter in height. I use the light theme, so I expect black text on white background.</p>
  
  <pre><code>tv.setTextAppearance(this, android.R.attr.textAppearanceSmall);
  tv.setVisibility(View.VISIBLE);
  tv.setBackgroundColor(Color.TRANSPARENT);
  tv.setTextColor(Color.BLACK);
  </code></pre>
  
  <p>were added at a second time when everything was failing. No difference whether they are in place or not. What can I do to fix?</p>
  
  <p>Thanks</p>