Xamarin Android ActionBar Tabs - 1 tab not showing text

I have added an actionBar tab to a fragment of my project, but one of the tabs does not display the text. The tab shows, and i can click the tab, but there is no text or icon on the tab. Here is the code:

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState)
     {
        HasOptionsMenu = true;
        var ignored = base.OnCreateView (inflater, container, savedInstanceState);

        this.Activity.ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

        var tab = this.Activity.ActionBar.NewTab ();
        tab.SetText ("List"); //this one not showing up
        tab.SetIcon (Resource.Drawable.Icon);

        var tab2 = this.Activity.ActionBar.NewTab ();
        tab.SetText ("Map");
        tab.SetIcon (Resource.Drawable.Icon);




        var view = inflater.Inflate(Resource.Layout.OffersLayout, null);


        tab.TabSelected += delegate {
                    //some stuff
        };

        tab2.TabSelected += delegate {
                    //some stuff
        };

        this.Activity.ActionBar.AddTab (tab);
        this.Activity.ActionBar.AddTab (tab2);

Any idea what i'm doing wrong here?

Upvotes: 1

Views: 764

Answers (1)

matthewrdev
matthewrdev

Reputation: 12190

You've got a typo, you're setting the title only on tab1:

    var tab2 = this.Activity.ActionBar.NewTab ();
    tab.SetText ("Map"); // This should be tab2.
    tab.SetIcon (Resource.Drawable.Icon); // This should be tab2

Upvotes: 1

Related Questions