title: Monodroid tabs view
body: <p>After implementing the <a href="http://android.xamarin.com/Tutorials/Hello_Views/Tab_Widget" rel="nofollow">Tabs Widget Sample</a> I tried to play with it and add the third tab only after changing to the second tab</p>
  
  <pre><code>protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
  
          // Set our view from the "main" layout resource  
          SetContentView(Resource.Layout.Main);
  
          TabHost.TabSpec spec;
  
          spec = TabHost.NewTabSpec("tab_test1").SetIndicator("TAB 1").SetContent(Resource.Id.textview1);
          TabHost.AddTab(spec);
  
          spec = TabHost.NewTabSpec("tab_test2").SetIndicator("TAB 2").SetContent(Resource.Id.textview2);
          TabHost.AddTab(spec);
  
          //spec = TabHost.NewTabSpec("tab_test3").SetIndicator("TAB 3").SetContent(Resource.Id.widget0);
          //TabHost.AddTab(spec);
  
          TabHost.TabChanged += new EventHandler&lt;Android.Widget.TabHost.TabChangeEventArgs&gt;(TabHost_TabChanged);
  
          TabHost.CurrentTab = 0;
      }
  
      void TabHost_TabChanged(object sender, TabHost.TabChangeEventArgs e)
      {
          if (TabHost.TabWidget.TabCount &lt; 3)
          {
              TabHost.TabSpec spec;
  
              spec = TabHost.NewTabSpec("tab_test3").SetIndicator("TAB 3").SetContent(Resource.Id.widget0);
              TabHost.AddTab(spec);
          }
      }
  </code></pre>
  
  <p>The problem is that I see the 3rd view overlay-ed on the first view before clicking the tabs, even though the 3rd tab appears only after clicking the 2nd tab. What's going on? </p>