Exemplo n.º 1
0
        private void nav_NavigationItemSelected(object sender, NavigationEventArgs args)
        {
            var containerResId = Resource.Id.fragment_container;

            var transaction = SupportFragmentManager.BeginTransaction();
            transaction.SetTransition((int)SupportFragmentTransaction.TransitFragmentOpen);

            if (args.NavItemPosition == NavigationDestination.List) {
                list_fragment = list_fragment ?? new SampleListFragment();
                list_fragment.FastScrollEnabled = false;
                transaction.Replace(containerResId, list_fragment);
            } else if (args.NavItemPosition == NavigationDestination.Grid) {
                grid_fragment = grid_fragment ?? new GridFragment();
                transaction.Replace(containerResId, grid_fragment);
            } else if (args.NavItemPosition == NavigationDestination.ScrollView) {
                image_fragment = new ImageFragment(Resource.Drawable.android_flavors);
                transaction.Replace(containerResId, image_fragment);
            } else if (args.NavItemPosition == NavigationDestination.ListFastScroll) {
                list_fragment = list_fragment ?? new SampleListFragment();
                list_fragment.FastScrollEnabled = true;
                transaction.Replace(containerResId, list_fragment);
            } else if (args.NavItemPosition == NavigationDestination.ExpandableList) {
                expandablelist_fragment = expandablelist_fragment ?? new ExpandableListFragment();
                transaction.Replace(containerResId, expandablelist_fragment);
            }

            transaction.AddToBackStack(null);
            transaction.Commit();
        }
Exemplo n.º 2
0
        private void nav_NavigationItemSelected(object sender, NavigationEventArgs args)
        {
            var containerResId = Resource.Id.fragment_container;

            var transaction = SupportFragmentManager.BeginTransaction();
            transaction.SetTransition((int)SupportFragmentTransaction.TransitFragmentOpen);

            if (args.NavItemPosition == 0) {
                list_fragment = list_fragment ?? new SampleListFragment();
                transaction.Replace(containerResId, list_fragment);
            } else if (args.NavItemPosition == 1) {
                grid_fragment = grid_fragment ?? new GridFragment();
                transaction.Replace(containerResId, grid_fragment);
            } else if (args.NavItemPosition == 2) {
                image_fragment = new ImageFragment(Resource.Drawable.android_flavors);
                transaction.Replace(containerResId, image_fragment);
            }

            transaction.AddToBackStack(null);
            transaction.Commit();
        }