Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            var drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            var fragment            = new Fragments.HomeFragment();
            var fragmentTransaction = FragmentManager.BeginTransaction();

            fragmentTransaction.Replace(Resource.Id.framecontainer, fragment);
            fragmentTransaction.AddToBackStack(null);
            fragmentTransaction.Commit();
        }
Exemplo n.º 2
0
        public void goHome()
        {
            var fragment            = new Fragments.HomeFragment();
            var fragmentTransaction = FragmentManager.BeginTransaction();

            fragmentTransaction.Replace(Resource.Id.framecontainer, fragment);
            fragmentTransaction.AddToBackStack(null);
            fragmentTransaction.Commit();
        }
Exemplo n.º 3
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            var      id       = item.ItemId;
            Fragment fragment = null;

            switch (id)
            {
            default:
                break;

            case Resource.Id.nav_home:
                fragment = new Fragments.HomeFragment();
                break;

            case Resource.Id.nav_english:
                fragment = new Fragments.English.EnglishHomeFragment();
                break;

            case Resource.Id.nav_maths:
                fragment = new Fragments.Maths.MathsHomeFragment();
                break;

            case Resource.Id.nav_geography:
                break;

            case Resource.Id.nav_history:
                break;

            case Resource.Id.nav_computing:
                fragment = new Fragments.Computing.ComputingHomeFragment();
                break;

            case Resource.Id.nav_share:
                break;

            case Resource.Id.nav_feedback:
                sendFeedback();
                return(false);

            case Resource.Id.nav_about:
                break;
            }

            if (fragment != null)
            {
                //home_fragment
                var fragmentTransaction = FragmentManager.BeginTransaction();
                fragmentTransaction.Replace(Resource.Id.framecontainer, fragment);
                fragmentTransaction.AddToBackStack(null);
                fragmentTransaction.Commit();

                var drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer.CloseDrawer(GravityCompat.Start);
                return(true);
            }
            else
            {
                Common.notImplementedWarning(FindViewById(Android.Resource.Id.Content), ApplicationContext);
                return(false);
            }
        }