コード例 #1
0
        void PopulateItemDetail(Item itemDetail)
        {
            int iconid = Item.GetIconId(itemDetail.ResourceName, this);

            if (iconid > 0)
            {
                this.ActionBar.SetIcon(iconid);
            }
            detailsFragment = new ItemDetailsTabFragment(itemDetail);
            detailsTab.SetTag(detailsFragment);
            var transaction = this.FragmentManager.BeginTransaction();

            transaction.Replace(R.Ids.itemDetailFragmentContainer, detailsFragment);
            transaction.Commit();
            stocksFragment = new ItemStationStockTabFragment(itemDetail);
            stockTab.SetTag(stocksFragment);
            if (itemDetail.Producers.Count > 0)
            {
                producersFragment = new ItemProducersTabFragment(itemDetail);
                producersTab.SetTag(producersFragment);
            }
            else
            {
                this.ActionBar.RemoveTab(producersTab);
            }
            this.ActionBar.Title = itemDetail.Name;
            if (pd != null)
            {
                pd.Dismiss();
            }
        }
コード例 #2
0
        void initTab()
        {
            scan_Fragment  = new Scan_Fragment();
            set_Fragment   = new Set_Fragment();
            write_Fragment = new Write_Fragment();
            read_Fragment  = new Read_Fragment();

            actionBar = ActionBar;
            actionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            actionBar.SetDisplayHomeAsUpEnabled(true);

            ActionBar.Tab tab1 = actionBar.NewTab();
            tab1.SetTag("Scan");
            tab1.SetText(Resource.String.tab_Scan);
            tab1.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
                e.FragmentTransaction.Replace(Android.Resource.Id.Content, scan_Fragment);
            };

            ActionBar.Tab tab2 = actionBar.NewTab();
            tab1.SetTag("Write");
            tab2.SetText(Resource.String.tab_WriteData);
            tab2.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
                e.FragmentTransaction.Replace(Android.Resource.Id.Content, write_Fragment);
            };
            ActionBar.Tab tab3 = actionBar.NewTab();
            tab1.SetTag("Read");
            tab3.SetText(Resource.String.tab_ReadData);
            tab3.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
                e.FragmentTransaction.Replace(Android.Resource.Id.Content, read_Fragment);
            };

            ActionBar.Tab tab4 = actionBar.NewTab();
            tab1.SetTag("set");
            tab4.SetText(Resource.String.tab_set);
            tab4.TabSelected += (object sender, ActionBar.TabEventArgs e) => {
                e.FragmentTransaction.Replace(Android.Resource.Id.Content, set_Fragment);
            };
            actionBar.AddTab(tab1);
            actionBar.AddTab(tab2);
            actionBar.AddTab(tab3);
            actionBar.AddTab(tab4);
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layouts.ItemDetailActivity_Layout);

            var itemID   = Intent.GetLongExtra("itemID", 0);
            var itemName = Intent.GetStringExtra("itemName");

            this.ActionBar.SetTitle(itemName);
            this.ActionBar.NavigationMode = ActionBar.NAVIGATION_MODE_TABS;

            detailsFragment = new ItemDetailsTabFragment(null);
            detailsTab      = this.ActionBar.NewTab();
            detailsTab.SetText("Details");
            detailsTab.SetTabListener(this);
            detailsTab.SetTag(detailsFragment);
            this.ActionBar.AddTab(detailsTab);

            stocksFragment = new ItemStationStockTabFragment(null);
            stockTab       = this.ActionBar.NewTab();
            stockTab.SetText("Stock");
            stockTab.SetTabListener(this);
            stockTab.SetTag(stocksFragment);
            this.ActionBar.AddTab(stockTab);

            producersFragment = new ItemProducersTabFragment(null);
            producersTab      = this.ActionBar.NewTab();
            producersTab.SetText("Production");
            producersTab.SetTabListener(this);
            producersTab.SetTag(producersFragment);
            this.ActionBar.AddTab(producersTab);

            if (itemID == 0)
            {
                Android.Widget.Toast.MakeText(this, "Item ID Error!", Android.Widget.Toast.LENGTH_LONG).Show();
            }

            var itemDetail = LastNonConfigurationInstance as Item;

            if ((itemDetail != null) && (itemDetail.ItemID == itemID))
            {
                _savedInstance = itemDetail;
                PopulateItemDetail(itemDetail);
            }
            else
            {
                RefreshItemDetail(itemID);
            }
        }