title: Working with Tab Control - Mono for Android
body: <p>I have following Tab control in my activity. It contains 2 tabs. </p>
  
  <p>On Click of <code>Tab</code>, it should navigate to a new <code>activity</code>.</p>
  
  <p>But I'm having 2 issues with it.</p>
  
  <p><strong>1.)</strong> it is giving me <code>IllegalArgumentException</code> when following code is used : </p>
  
  <pre><code>    TabHost tabHost=(TabHost)FindViewById(Resource.Id.tabHost);
              tabHost.Setup();
  
      TabHost.TabSpec spec1=tabHost.NewTabSpec("Tab 1");
              spec1.SetContent(Resource.Id.tab1);
              Intent i = new Intent(this, typeof(Activity1));
              spec1.SetContent(i);
              spec1.SetIndicator("Tab 1");
  
      TabHost.TabSpec spec2=tabHost.NewTabSpec("Tab 2");
              spec2.SetContent(Resource.Id.tab2);
              Intent i = new Intent(this, typeof(Activity2));
              spec2.SetContent(i);
              spec2.SetIndicator("Tab 2");
  
          tabHost.AddTab(spec1);
          tabHost.AddTab(spec2);
  </code></pre>
  
  <p><strong>2.)</strong> and for demo purpose , I tried this simple code : </p>
  
  <pre><code>TabHost tabHost=(TabHost)FindViewById(Resource.Id.tabHost);
   tabHost.Setup(); 
  
  TabHost.TabSpec spec1=tabHost.NewTabSpec("Tab 1");
  spec1.SetContent(Resource.Id.tab1);
  spec1.SetIndicator("Tab 1");
  
  TabHost.TabSpec spec2=tabHost.NewTabSpec("Tab 2");
  spec2.SetContent(Resource.Id.tab2);
  spec2.SetIndicator("Tab 2");
  
  tabHost.AddTab(spec1);
  tabHost.AddTab(spec2);
  </code></pre>
  
  <p>But it this case, <code>Tab</code> is <strong>always taking the focus</strong>.</p>
  
  <p>i.e. I have a <code>EditText</code> in my activity and as soon as I try to type something in it, focus goes to <code>Tab</code>. </p>
  
  <p>I have no idea why this is happening, any solution?</p>
  
  <p>I'm absolute beginner to mono for android, so any help appreciated..</p>
  
  <h2>EDIT</h2>
  
  <p>Considering the suggestions, I used this :</p>
  
  <pre><code>TabHost.TabSpec spec;     
          Intent intent;
  
  TabHost tabHost=(TabHost)FindViewById(Resource.Id.tabHost);
                  tabHost.Setup();
  
              intent = new Intent (this, typeof (HeatMap));
              intent.AddFlags (ActivityFlags.NewTask);
  
              spec=tabHost.NewTabSpec("Heat Map");
              spec.SetIndicator("Heat Map");
              spec.SetContent(intent);
              tabHost.AddTab(spec);
  
              intent = new Intent (this, typeof (LiveMkt));
              intent.AddFlags (ActivityFlags.NewTask);
  
              spec=tabHost.NewTabSpec("Live Mkt");
              spec.SetIndicator("Live Mkt");
              spec.SetContent(intent);
              tabHost.AddTab(spec);
  </code></pre>
  
  <p>But I got this error:</p>
  
  <pre><code> java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?    
  android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:649)     
  android.widget.TabHost.setCurrentTab(TabHost.java:323)
  android.widget.TabHost.addTab(TabHost.java:213)
  stockgadget.controls.HeatMap.n_onCreate(Native Method)
  stockgadget.controls.HeatMap.onCreate(HeatMap.java:25)
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  android.app.ActivityThread.access$2300(ActivityThread.java:125)
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  android.os.Handler.dispatchMessage(Handler.java:99)
  android.os.Looper.loop(Looper.java:123)
  </code></pre>