Exemplo n.º 1
0
        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 = Fragment1.NewInstance();
                break;

            case 1:
                fragment = Fragment2.NewInstance();
                break;

            case 2:
                fragment = Fragment3.NewInstance();
                break;

            case 3:
                fragment = Fragment4.NewInstance();
                break;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
Exemplo n.º 2
0
        void LoadFragment(int id)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.Gezondheid:
                fragment = Fragment1.NewInstance();
                break;

            case Resource.Id.Style:
                fragment = Fragment2.NewInstance();
                break;

            case Resource.Id.Minigames:
                fragment = Fragment3.NewInstance();
                break;

            default:
            case Resource.Id.home:
                fragment = Home.NewInstance();
                break;
            }
            if (fragment == null)
            {
                return;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
Exemplo n.º 3
0
        void LoadFragment(int id)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.menu_list:
                fragment = Fragment1.NewInstance();
                break;

            case Resource.Id.menu_add:
                fragment = Fragment2.NewInstance();
                break;
                //case Resource.Id.menu_video:
                //    fragment = Fragment3.NewInstance();
                //    break;
            }
            if (fragment == null)
            {
                return;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
        public FragmentManager(AppCompatActivity host)
        {
            Fragment1 = new Fragment1();
            Fragment2 = new Fragment2();
            Fragment3 = new Fragment3();
            mHost     = host;

            mFragmentTrans  = mHost.SupportFragmentManager.BeginTransaction();
            CurrentFragment = Fragment1;
        }
Exemplo n.º 5
0
            public override Android.Support.V4.App.Fragment GetItem(int position)
            {
                switch (position)
                {
                case 0:
                    return(Fragment1.NewInstance());

                case 1:
                    return(Fragment2.NewInstance());
                }
                return(null);
            }
Exemplo n.º 6
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            v4.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();

            int?titleId = null;

            v4.Fragment fragment = null;

            if (id == Resource.Id.nav_camera)
            {
                // Handle the camera action
            }
            else if (id == Resource.Id.nav_gallery)
            {
                titleId  = Resource.String.gallery_title;
                fragment = new Fragment1();
            }
            else if (id == Resource.Id.nav_slideshow)
            {
            }
            else if (id == Resource.Id.nav_manage)
            {
                titleId  = Resource.String.manage_title;
                fragment = new Fragment2();
            }
            else if (id == Resource.Id.nav_share)
            {
            }
            else if (id == Resource.Id.nav_send)
            {
            }

            if (titleId != null)
            {
                SupportActionBar.SetTitle((int)titleId);
            }

            if (fragment != null)
            {
                ft.Replace(Resource.Id.fragment_container, fragment);
                ft.AddToBackStack(null);
                ft.Commit();
            }

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            bottomNavigation = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);
            bottomNavigation.NavigationItemSelected += (s, e) =>
            {
                Android.Support.V4.App.Fragment fragment = null;
                switch (e.Item.ItemId)
                {
                case Resource.Id.Food:
                    fragment = new Fragment1();
                    break;

                case Resource.Id.Tourist:
                    fragment = new Fragment2();
                    break;

                case Resource.Id.History:
                    fragment = new Fragment3();
                    break;
                }
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragmentContainer, fragment)
                .Commit();

                return;
            };

            mFragment1 = new Fragment1();
            mFragment2 = new Fragment2();
            mFragment3 = new Fragment3();

            mStackFragment = new Stack <SupportFragment>();

            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.fragmentContainer, mFragment3, "Fragment3");//NOT bottom_navigation, it must be the container
            trans.Hide(mFragment3);
            trans.Add(Resource.Id.fragmentContainer, mFragment2, "Fragment2");
            trans.Hide(mFragment2);
            trans.Add(Resource.Id.fragmentContainer, mFragment1, "Fragment1");
            trans.Commit();

            mCurrentFragment = mFragment1;
        }
Exemplo n.º 8
0
        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 = Fragment1.NewInstance();
                break;

            case 1:
                fragment = Fragment2.NewInstance();
                break;

            case 2:
                fragment = BookingStatusListFragment.NewInstance();
                break;

            case 7:
                Auth.GoogleSignInApi.SignOut(googleApiClient).SetResultCallback(new SignOutResultCallback {
                    Activity = this
                });
                LoginActivity.mgoogleApiClient.Disconnect();



                StartActivity(typeof(LoginActivity));
                Finish();
                break;
            }
            if (position != 7 && fragment != null)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
        }
Exemplo n.º 9
0
        void LoadFragment(int id)
        {
            Fragment fragment = null;

            switch (id)
            {
            case Resource.Id.action_add:
                fragment = Fragment1.NewInstance();
                break;

            case Resource.Id.action_edit:
                fragment = Fragment2.NewInstance();
                break;

            case Resource.Id.action_remove:
                fragment = Fragment3.NewInstance();
                break;

            case Resource.Id.action_select:
                fragment = Fragment4.NewInstance();
                break;

            case Resource.Id.action_batata:
                fragment = Fragment5.NewInstance();
                break;
            }
            if (fragment == null)
            {
                return;
            }
            else
            {
                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .AddToBackStack(fragment.Tag)
                .Commit();
            }
        }
Exemplo n.º 10
0
        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 Resource.Id.nav_home_1:
                fragment = LoginFragment.NewInstance();
                break;

            case Resource.Id.nav_home_2:
                fragment = Fragment2.NewInstance();
                break;

            case (int)MenuType.LoginMenu:
                fragment = LoginFragment.NewInstance();
                break;

            case (int)MenuType.Top10Menu:
                fragment = Top10Fragment.NewInstance();
                break;

            case (int)MenuType.ThreadMenu:
                fragment = ArticleContentFragment.NewInstance();
                break;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
Exemplo n.º 11
0
        private void ListItemClicked(int position)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
                case 0:
                    fragment = new Fragment1();
                    break;
                case 1:
                    fragment = new Fragment2();
                    break;
                case 2:
				fragment = new Fragment3(this);
                    break;
			default:
				fragment = new Fragment1 ();
				break;
            }

            SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();

            drawerList.SetItemChecked(position, true);
            SupportActionBar.Title = title = Sections[position];
            drawer.CloseDrawer(drawerList);
        }
Exemplo n.º 12
0
        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:
                //Se resetea el fragmento del mapa
                resetearMapa();
                fragment = FragmentLogin.NewInstance();
                //SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
                break;

            case 1:
                //Se resetea el fragmento del mapa
                resetearMapa();
                fragment = Fragment1.NewInstance();
                //SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
                break;

            case 2:
                //Se resetea el fragmento del mapa
                resetearMapa();
                fragment = FragmentMap.NewInstance();
                //SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
                break;

            case 3:
                //Se resetea el fragmento del mapa
                resetearMapa();
                fragment = Impresion.NewInstance(codigoNotificacion, notificado);
                //SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
                break;

            case 4:
                //Se resetea el fragmento del mapa
                resetearMapa();
                fragment = RolNocturno.NewInstance();
                // SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
                break;

            case 5:
                //Es el de prueba
                fragment = Fragment2.NewInstance("12345");
                break;

            default:
                Console.WriteLine("Elemento seleccionado " + position.ToString());
                break;
            }

            SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            mToolbar      = FindViewById <SupportToolbar>(Resource.Id.toolbar);
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            mLeftDrawer   = FindViewById <ListView>(Resource.Id.left_drawer);
            mRightDrawer  = FindViewById <ListView>(Resource.Id.right_drawer);

            mFragment1 = new Fragment1();
            mFragment2 = new Fragment2();
            mFragment3 = new Fragment3();
            mFragment4 = new Fragment4();
            mFragment5 = new Fragment5();

            mStackFragment   = new Stack <SupportFragment>();
            mLeftDrawer.Tag  = 0;
            mRightDrawer.Tag = 1;

            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List <string>();
            mLeftDataSet.Add("Home");
            mLeftDataSet.Add("Search");
            mLeftDataSet.Add("Search Map");
            mLeftAdapter        = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter = mLeftAdapter;

            mRightDataSet = new List <string>();
            mRightDataSet.Add("About");
            mRightDataSet.Add("Contact Us");
            mRightAdapter        = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, mRightDataSet);
            mRightDrawer.Adapter = mRightAdapter;


            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.fragmentContainer, mFragment5, "Fragment5");
            trans.Hide(mFragment5);
            trans.Add(Resource.Id.fragmentContainer, mFragment4, "Fragment4");
            trans.Hide(mFragment4);
            trans.Add(Resource.Id.fragmentContainer, mFragment3, "Fragment3");
            trans.Hide(mFragment3);
            trans.Add(Resource.Id.fragmentContainer, mFragment2, "Fragment2");
            trans.Hide(mFragment2);
            trans.Add(Resource.Id.fragmentContainer, mFragment1, "Fragment1");
            trans.Commit();

            mCurrentFRagment = mFragment1;

            mDrawerLayout.AddDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            mDrawerToggle.SyncState();

            if (bundle != null)
            {
                if (bundle.GetString("DrawerState") == "Opened")
                {
                    SupportActionBar.SetTitle(Resource.String.openDrawer);
                }
                else
                {
                    SupportActionBar.SetTitle(Resource.String.closeDrawer);
                }
            }
            else
            {
                SupportActionBar.SetTitle(Resource.String.closeDrawer);
            }
        }