title: Android - Adding tabs Dynamically
body: <p>I have to add n number of tabs with the same layout (say llItemList which is declared in xml) in all the tabs.  In the below snippet when I create n number of tabs. All the layout uses the same copy of llItemList, instead of the tab's own copy. Could you please let me know how to create a individual copy of llItemList in all the tabs which will be created dynamically. 
  Thanks in Advance</p>
  
  <pre><code>    //---------------------------------
      // insert the tabs dynamically
      //--------------------------------- 
      for (int i=1; i&lt;=n; i++){
          final String tabName = "tab" + Integer.toString(i);
          final TabSpec ourSpec = th.newTabSpec(tabName);
          ourSpec.setContent(new TabHost.TabContentFactory() { 
              public View createTabContent(String tag) { 
              ourSpec.setContent(R.id.llItemList);   
              TextView text = new TextView(NewTicket.this);
              String tabText = tabName;
              text.setText("You've created a new tab " + tabText); 
              return (text);
              }
          });
          ourSpec.setIndicator(tabName);
          th.addTab(ourSpec);
      }
  </code></pre>