protected override void OnCreate(Bundle savedInstanceState) { //Status Bar Color this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Console.WriteLine("Status Bar Color! "); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); // Init toolbar var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.app_bar); SetSupportActionBar(toolbar); SupportActionBar.SetTitle(Resource.String.product_name); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); // Attach item selected handler to navigation view var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected; // Create ActionBarDrawerToggle button and add it to the toolbar var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer); //Linea corregida de Set a Add porque era obsoleta drawerLayout.AddDrawerListener(drawerToggle); drawerToggle.SyncState(); homeFragment = new HomeFragment(); writeFragment = new WriteFragment(); productsFragment = new ProductsFragment(); cartFragment = new CartFragment(); corridaFinancieraFragment = new CorridaFinancieraFragment(); mStackFragment = new Stack <Fragment>(); //load default home screen //var ft = FragmentManager.BeginTransaction(); //ft.AddToBackStack(null); //ft.Add(Resource.Id.HomeFrameLayout, new HomeFragment()); //ft.Commit(); var trans = FragmentManager.BeginTransaction(); //trans.AddToBackStack(null); trans.Add(Resource.Id.HomeFrameLayout, cartFragment, "Carrito Compras"); trans.Hide(cartFragment); trans.Add(Resource.Id.HomeFrameLayout, corridaFinancieraFragment, "Corrida Financiera"); trans.Hide(corridaFinancieraFragment); trans.Add(Resource.Id.HomeFrameLayout, homeFragment, "Home"); trans.Hide(homeFragment); trans.Add(Resource.Id.HomeFrameLayout, writeFragment, "pesan"); trans.Hide(writeFragment); trans.Add(Resource.Id.HomeFrameLayout, productsFragment, "Productos"); trans.Commit(); mCurrentFragment = productsFragment; }
private void ListItemClicked(int position) { Android.Support.V4.App.Fragment fragment = null; switch (position) { case 0: fragment = ProductsFragment.NewInstance(); break; } SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); mCheckoutFragment = new CheckoutFragment(); mProductsFragment = new ProductsFragment(); mCustomersFragment = new CustomersFragment(); mTransactionsFragment = new TransactionsFragment(); mSettingsFragment = new SettingsFragment(); mStackFragment = new Stack <SupportFragment>(); SupportToolbar toolBar = FindViewById <SupportToolbar>(Resource.Id.main_toolbar); SetSupportActionBar(toolBar); SupportActionBar ab = SupportActionBar; ab.SetHomeAsUpIndicator(Resource.Drawable.menu_icon_small); ab.SetDisplayHomeAsUpEnabled(true); ab.SetTitle(Resource.String.checkout_title); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); if (navigationView != null) { SetUpDrawerContent(navigationView); } var trans = SupportFragmentManager.BeginTransaction(); trans.Add(Resource.Id.fragmentContainer, mSettingsFragment, "SettingsFragment"); trans.Hide(mSettingsFragment); trans.Add(Resource.Id.fragmentContainer, mTransactionsFragment, "TransactionsFragment"); trans.Hide(mTransactionsFragment); trans.Add(Resource.Id.fragmentContainer, mCustomersFragment, "CustomersFragment"); trans.Hide(mCustomersFragment); trans.Add(Resource.Id.fragmentContainer, mProductsFragment, "ProductsFragment"); trans.Hide(mProductsFragment); trans.Add(Resource.Id.fragmentContainer, mCheckoutFragment, "CheckoutFragment"); trans.Commit(); mCurrentFragment = mCheckoutFragment; }
private void ListItemClicked(int position) { //this way we don't load twice, but you might want to modify this a bit. if (position == oldPosition) { return; } oldPosition = position; Android.Support.V4.App.Fragment fragment = null; switch (position) { case 0: fragment = HomeFragment.NewInstance(); break; case 1: fragment = LocationsFragment.NewInstance(); break; case 2: fragment = AddItemBarcodeFragment.NewInstance(); break; case 3: fragment = StoragesFragment.NewInstance(); break; case 4: fragment = CategoriesFragment.NewInstance(); break; case 5: fragment = ProductsFragment.NewInstance(); break; case 6: fragment = ShopListFragment.NewInstance(); break; case 7: fragment = SummaryFragment.NewInstance(); break; } SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); }