title: Adding a view dynamically not showing view
body: <p>I am using following code to inflate a view in my layout under its child LinearLayout: </p>
  
  <pre><code>LayoutInflater vi = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View v = vi.inflate(R.layout.your_layout, null);
  // fill in any details dynamically here
  TextView textView = (TextView) v.findViewById(R.id.a_text_view);
   textView.setText("your text");
  // insert into main view
  View insertPoint = findViewById(R.id.insert_point);
  ((ViewGroup) insertPoint).addView(v, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  </code></pre>
  
  <p>But I can't see my view there. It shows up when I rotate my screen to landscape view. How to fix this?</p>
  
  <p>EDIT: </p>
  
  <p>Here is basically what I am doing. I have a TabActivity with two tabs. I use an application global which store a flag and TabHost of my TabActivity. I am also using a thread in the second tab activity which is monitoring the application global continuously to monitor flag.  When I click a button in my first tab, I set the global to true. The thread in the second tab check its value. When it gets true, I run the async task and shift the current showing window to the second tab using my TabHost stired in ApplicationGlobal.</p>
  
  <p>Code of second tab:</p>
  
  <pre><code>public class ShowDownloadsActivity extends Activity {
      private List&lt;String&gt; list;
      ApplicationGlobal ap;
      String tempUrl = "";
      LinearLayout lly;
      LayoutInflater inflater;
      Context con;
      static int k = 0;
      static int tmp = 0;
      static int size = 0;
      View insertPoint;
      View v;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.shwds);
          con = this;
          v = LayoutInflater.from(this).inflate(R.layout.downloadlistrow, null);
          insertPoint = (View) findViewById(R.id.layout_vids);
          inflater = (LayoutInflater) con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          ap = (ApplicationGlobal) getApplication();
          lly = (LinearLayout) findViewById(R.id.layout_vids);
  
          Thread thread1 = new Thread() {
              public void run() {
                  try {
                      boolean flg = ap.getFlag();
                      if (flg) {
                          tempUrl = ap.getUrl();
                          ap.setUrl("");
                          flg = false;
                          new downloadVideo().execute();
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          };
          thread1.run();
      }
  
      class downloadVideo extends AsyncTask&lt;Hashtable&lt;String, String&gt;, String, String&gt; {
          String resp = "";
  
          protected void onProgressUpdate(String... values) {
  
          }
  
          @Override
          protected void onPreExecute() {
              // fill in any details dynamically here 
              TextView textView = (TextView) v.findViewById(R.id.siz);
              textView.setText("your text");
              // insert into main view 
              addContentView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
              super.onPreExecute();
          }
  
          @Override
          protected String doInBackground(Hashtable&lt;String, String&gt;... prmss) {
              try {
                  final int return resp;
              }
  
              @Override
              protected void onPostExecute (String result){
                  super.onPostExecute(result);
              }
          }
      }
  }
  </code></pre>