Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8863923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:06:37+00:00 2026-06-14T16:06:37+00:00

I have a little problem, which I can’t solve.. Well, I built a BaseActivity.cs

  • 0

I have a little problem, which I can’t solve..

Well, I built a BaseActivity.cs Class:

public class BaseActivity<T> : MvxBindingTabActivityView<T> 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) => { Console.WriteLine("OK Button clicked, alert dismissed"); });
            ad.Show();
        }
        return true;
    }
}

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..

Then my other two Activities which are inheriting from BaseActivity.cs:

the MainScreenActivity.cs:

[Activity]
public class MainScreenActivity : BaseActivity<MainScreenViewModel>
{
    protected override void OnViewModelSet()
    {
        SetContentView(Resource.Layout.MainScreenLayout);

        TabHost.TabSpec spec;    
        Intent intent;

        intent = base.CreateIntentFor<AddressesSearchViewModel>();
        intent.AddFlags(ActivityFlags.NewTask);

        spec = TabHost.NewTabSpec("adressen");
        spec.SetIndicator("Adressen");
        spec.SetContent(intent);
        TabHost.AddTab(spec);


        intent = base.CreateIntentFor<ContactsSearchViewModel>();
        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);
    }
}

and the LoginActivity.cs:

[Activity]
public class LoginActivity : BaseActivity<LoginViewModel>
{
    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<ErrorMessage>((m) => { ErrorMessageAlert(m.Message, m.Title); });
    }
}

Its compiling fine, but the app crashes when I start it, and thats the errormessage I get: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost‘ . I suggest, that it is because I “needed” to implement the abstract interface into the BaseActivity.cs :

protected override void OnViewModelSet()
{ }

So maybe he walks into the ‘false’ OnViewModelSet(), (In the empty one instead of the one which is building the Tabhost).. but I’m actually not sure.. btw this comes from: MvxBindingTabActivityView..

Hmm any help would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:06:38+00:00Added an answer on June 14, 2026 at 4:06 pm

    I think this is a quite simple problem…

    MvxBindingTabActivityView inherits from TabActivity (see source) and it’s this class that requires the content – Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'

    If you don’t want to use Tabs, then just inherit from MvxBindingActivityView instead – this is what the conference sample does – https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20CirriousConference/Cirrious.Conference.UI.Droid/Views/BaseView.cs

    If one of your activities needs to do tabs, but the other doesn’t then they need to inherit using different inheritance trees. If you want to share code between the two base classes, then the best way to do this in C# seems to be using extension methods – e.g. see BaseViewExtensionMethods.cs shared between BaseView.cs, BaseTabbedView.cs and BaseMapView.cs in the conference sample.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem which I have no clue how to solve. I
I have a little problem I can't solve so far. In BPEL I want
I have this little problem, that I cannot figure out which arguments to pass
I'm with a little problem. I have the container div for some elements which
I have little unusual problem to solve. I need some hint or links to
i have little problem how i will recognize which item was clicked with OnClickEvent.
I have a little problem with Xcode. I import a header which contains this
Hey guys! I have this little problem: I have one ViewController which adds 2
Evening :) I have a little problem... As you can see in my code
I have one problem in which i simply want to know how i can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.