title: MVVMCross - BaseActivity and OnViewModelSet()
body: <p>I have a little problem, which I can't solve..</p>
  
  <p>Well, I built a <strong>BaseActivity.cs</strong> Class:</p>
  
  <pre><code>public class BaseActivity&lt;T&gt; : MvxBindingTabActivityView&lt;T&gt; where T : class, IMvxViewModel
  {
      protected override void OnViewModelSet()
      { }
  
      public override bool OnCreateOptionsMenu(IMenu menu)
      {
          // GroupId, ItemId, OrderId
          menu.Add(0, 0, 0, "Einstellungen").SetIcon(Android.Resource.Drawable.IcMenuManage);
          menu.Add(0, 1, 1, "Info").SetIcon(Android.Resource.Drawable.IcMenuInfoDetails);
          return true;
      }
  
      public override bool OnOptionsItemSelected(IMenuItem item)
      {
          var id = item.ItemId + 1; // (Id is zero-based :)
          if (id == 1) // First Item
          {
              StartActivity(typeof(SettingsShowActivity));
          }
          else if (id == 2) // Second Item
          {
              Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(this);
              AlertDialog ad = builder.Create();
              ad.SetTitle("Information");
              ad.SetIcon(Android.Resource.Drawable.IcDialogAlert);
              ad.SetMessage("Version: 0.1");
              ad.SetButton("OK", (s, e) =&gt; { Console.WriteLine("OK Button clicked, alert dismissed"); });
              ad.Show();
          }
          return true;
      }
  }
  </code></pre>
  
  <p>The goal of this class is, that I can put things in that I will use in every other Activity, just like here, the OptionsMenu, which is more or less on all Activities..</p>
  
  <p>Then my other two Activities which are inheriting from BaseActivity.cs:</p>
  
  <p>the <strong>MainScreenActivity.cs</strong>:</p>
  
  <pre><code>[Activity]
  public class MainScreenActivity : BaseActivity&lt;MainScreenViewModel&gt;
  {
      protected override void OnViewModelSet()
      {
          SetContentView(Resource.Layout.MainScreenLayout);
  
          TabHost.TabSpec spec;    
          Intent intent;
  
          intent = base.CreateIntentFor&lt;AddressesSearchViewModel&gt;();
          intent.AddFlags(ActivityFlags.NewTask);
  
          spec = TabHost.NewTabSpec("adressen");
          spec.SetIndicator("Adressen");
          spec.SetContent(intent);
          TabHost.AddTab(spec);
  
  
          intent = base.CreateIntentFor&lt;ContactsSearchViewModel&gt;();
          intent.AddFlags(ActivityFlags.NewTask);
  
          spec = TabHost.NewTabSpec("kontaktpersonen");
          spec.SetIndicator("Kontaktpersonen");
          spec.SetContent(intent);
          TabHost.AddTab(spec);
      }
  
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
      }
  }
  </code></pre>
  
  <p>and the <strong>LoginActivity.cs</strong>:</p>
  
  <pre><code>[Activity]
  public class LoginActivity : BaseActivity&lt;LoginViewModel&gt;
  {
      protected override void OnResume()
      {
          base.OnResume();
          App.IsLoggedIn = false;
      }
  
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
      }
  
      protected override void OnViewModelSet()
      {
          SetContentView(Resource.Layout.Login);
          //App.MessageHub.Subscribe&lt;ErrorMessage&gt;((m) =&gt; { ErrorMessageAlert(m.Message, m.Title); });
      }
  }
  </code></pre>
  
  <p>Its compiling fine, but the app crashes when I start it, and thats the errormessage I get: <code>Your content must have a TabHost whose id attribute is 'android.R.id.tabhost</code>' . I suggest, that it is because I "needed" to implement the abstract interface into the <strong>BaseActivity.cs</strong> :      </p>
  
  <pre><code>protected override void OnViewModelSet()
  { }
  </code></pre>
  
  <p>So maybe he walks into the 'false' <code>OnViewModelSet()</code>, (In the empty one instead of the one which is building the Tabhost).. but I'm actually not sure.. btw this comes from: <code>MvxBindingTabActivityView</code>.. </p>
  
  <p>Hmm any help would be appreciated </p>