title: Xamarin tab causes System.NullReferenceException
body: <p>I am trying to implement simple tab interface in my Xamarin Android application.
  My activity:</p>
  
  <pre><code>using System;
  
  using Android.App;
  using Android.Content;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using Android.OS;
  namespace SSMobile
  {
      [Activity (Label = "Tabs", MainLauncher = false, Icon = "@drawable/icon",Theme = "@android:style/Theme.NoTitleBar")]
      public class MainActivity : Activity 
      {
          protected override void OnCreate (Bundle bundle)
          {
              base.OnCreate (bundle);
              this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
              SetContentView (Resource.Layout.Main);
  
              AddTab ("Panic", Resource.Drawable.tab_icon, new PanicFragment ());
              AddTab ("Diagnostics", Resource.Drawable.tab_icon, new DiagnosticsFragment ());
              AddTab ("Config", Resource.Drawable.tab_icon, new ConfigFragment ());
          }
  
          protected override void OnSaveInstanceState(Bundle outState)
          {
              outState.PutInt("tab", this.ActionBar.SelectedNavigationIndex);
  
              base.OnSaveInstanceState(outState);
          }
  
          void AddTab (string tabText, int iconResourceId, Fragment view)
          {
              var tab = this.ActionBar.NewTab ();            
              tab.SetText (tabText);
              tab.SetIcon (Resource.Drawable.tab_icon);
  
              // must set event handler before adding tab
              tab.TabSelected += delegate(object sender, ActionBar.TabEventArgs e)
              {
                  var fragment = this.FragmentManager.FindFragmentById(Resource.Id.fragmentContainer);
                  if (fragment != null)
                      e.FragmentTransaction.Remove(fragment);         
                  e.FragmentTransaction.Add (Resource.Id.fragmentContainer, view);
              };
              tab.TabUnselected += delegate(object sender, ActionBar.TabEventArgs e) {
                  e.FragmentTransaction.Remove(view);
              };
  
              this.ActionBar.AddTab (tab);
          }
  
          class PanicFragment: Fragment {
              public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
              {
                  base.OnCreateView (inflater, container, savedInstanceState);
                  var view = inflater.Inflate (Resource.Layout.PanicFragment, container, false);
                  return view;
              }
          }
  
          class DiagnosticsFragment: Fragment {
              public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
              {
                  base.OnCreateView (inflater, container, savedInstanceState);
                  var view = inflater.Inflate (Resource.Layout.DiagnosticsFragment, container, false);
                  return view;
              }
          }
  
          class ConfigFragment: Fragment {
              public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
              {
                  base.OnCreateView (inflater, container, savedInstanceState);
                  var view = inflater.Inflate (Resource.Layout.ConfigFragment, container, false);
                  return view;
              }
          }
      }
  }
  </code></pre>
  
  <p>When my app is opening that activity, I get error:</p>
  
  <blockquote>
    <p>System.NullReferenceException: Object reference not set to an instance
    of an object</p>
  </blockquote>
  
  <p>on this line:</p>
  
  <pre><code>this.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
  </code></pre>
  
  <p>Exception log:</p>
  
  <pre><code>System.NullReferenceException: Object reference not set to an instance of an object
    at SSMobile.MainActivity.OnCreate (Android.OS.Bundle) [0x00009] in c:\Users\darek\Documents\Projects\SSMobile\SSMobile\MainActivity.cs:17
    at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1944
    at at (wrapper dynamic-method) object.3a5a286c-d028-4989-a49e-efabfb6b0ae6 (intptr,intptr,intptr) &lt;IL 0x00017, 0x0001f&gt;
  </code></pre>
  
  <p>What is wrong with this code?</p>