예제 #1
0
        void AddTab (TabHolder tabHolder)
        {
            var tab = ActionBar.NewTab ();
            tab.SetCustomView (IconProvider.CreateView (this, tabHolder.IconResource));

            tab.TabSelected += (sender, e) =>
            {
                var currentFragment = FragmentManager.FindFragmentById (Resource.Id.FragmentContainer);
                if (currentFragment != null)
                {
                    e.FragmentTransaction.Remove (currentFragment);
                }

                e.FragmentTransaction.Add (Resource.Id.FragmentContainer, tabHolder.Fragment);
            };
            tab.TabUnselected += (sender, e) => e.FragmentTransaction.Remove (tabHolder.Fragment);

            ActionBar.AddTab (tab);
        }
예제 #2
0
        void AddTab(TabHolder tabHolder)
        {
            var tab = ActionBar.NewTab();

            tab.SetCustomView(IconProvider.CreateView(this, tabHolder.IconResource));

            tab.TabSelected += (sender, e) =>
            {
                var currentFragment = FragmentManager.FindFragmentById(Resource.Id.FragmentContainer);
                if (currentFragment != null)
                {
                    e.FragmentTransaction.Remove(currentFragment);
                }

                e.FragmentTransaction.Add(Resource.Id.FragmentContainer, tabHolder.Fragment);
            };
            tab.TabUnselected += (sender, e) => e.FragmentTransaction.Remove(tabHolder.Fragment);

            ActionBar.AddTab(tab);
        }