void LoadFragment(int id)
        {
            Fragment fragment = null;

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

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

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

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

            default:
                break;
            }

            if (fragment == null)
            {
                return;
            }

            FragmentManager.BeginTransaction()
            .Replace(Resource.Id.fragmentContainer, fragment)
            .Commit();
        }
示例#2
0
        public static Fragment1 NewInstance()
        {
            var frag1 = new Fragment1 {
                Arguments = new Bundle()
            };

            return(frag1);
        }
示例#3
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;

            //Fragment fragment = null;

            Android.Support.V4.App.Fragment fragment = null;

            switch (position)
            {
            case 0:
                //fragment = Fragment1.NewInstance();
                FragmentTransaction ft = FragmentManager.BeginTransaction();
                Fragment            f1 = new Fragment1();
                ft.Replace(Resource.Layout.content_main, f1);
                ft.AddToBackStack(null);
                ft.Commit();
                //fragment = f1;
                break;
                //case 1:
                //    fragment = Fragment2.NewInstance();
                //    break;
                //case 2:
                //    fragment = Fragment3.NewInstance();
                //    break;

                //case 3:
                //    fragment = Fragment4.NewInstances();
                //    break;
                //case 4:
                //    fragment = Fragment5.NewInstances();
                //    break;
                //case 5:
                //    fragment = Fragment6.NewInstance();
                //    break;
                //case 6:
                //    fragment = Fragment7.NewInstances();
                //    break;
            }
            //SupportFragmentManager.BeginTransaction()
            //    .Replace(Resource.Layout.content_main,f1)
            //    .Commit();
        }
示例#4
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int      id       = item.ItemId;
            Fragment fragment = null;

            //    if (id == null)
            //{
            //    Toast.MakeText(this,"Hora Ramces Maradiaga",ToastLength.Long).Show();
            //}
            if (id == Resource.Id.nav_camera)
            {
                // Handle the camera action
                //FragmentTransaction ft = FragmentManager.BeginTransaction();
                //Fragment1 f1 = new Fragment1();
                //ft.Replace(Resource.Id.drawer_layout, f1);
                //ft.AddToBackStack(null);
                //ft.Commit();


                var prueba = Fragment1.NewInstance();
                //FragmentManager.BeginTransaction().Replace( Android.Resource.Id.Content,prueba).Commit();
                FragmentManager.BeginTransaction().Replace(Resource.Id.contenedor, prueba).Commit();
            }
            else if (id == Resource.Id.nav_gallery)
            {
                var prueba2 = Fragment2.NewInstance();
                //FragmentManager.BeginTransaction().Replace( Android.Resource.Id.Content,prueba).Commit();
                FragmentManager.BeginTransaction().Replace(Resource.Id.contenedor, prueba2).Commit();
            }
            else if (id == Resource.Id.nav_slideshow)
            {
            }
            else if (id == Resource.Id.nav_manage)
            {
            }
            else if (id == Resource.Id.nav_share)
            {
            }
            else if (id == Resource.Id.nav_send)
            {
            }

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

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }