コード例 #1
0
        void ListItemClicked(int position)
        {
            SupportFragmentManager.PopBackStack(null, (int)PopBackStackFlags.Inclusive);

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

            switch (position)
            {
            case 0:
                //load a map fragment directly from the API
                fragment = new SupportMapFragment();

                break;

            case 1:
                //load a fragment with a frame layout, create a SupportMapFragment,
                //and insert it into the frame layout
                fragment = new MyMapFragment();
                break;

            case 2:
                //load a fragment with a map fragment defined in the layout
                fragment = new MyMapFragment2();
                break;

            case 3:
                //example of map in a fragment sharing screen space with other controls
                fragment = new MyMapFragment3();
                break;

            default:

                break;
            }

            // Insert the fragment by replacing any existing fragment
            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();

            // Highlight the selected item, update the title, and close the drawer
            drawerList.SetItemChecked(position, true);
            SupportActionBar.Title = sections [position];
            drawerLayout.CloseDrawer(drawerList);
        }
コード例 #2
0
		void ListItemClicked (int position)
		{
			SupportFragmentManager.PopBackStack (null, (int)PopBackStackFlags.Inclusive);

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

			switch (position) 
			{
			case 0:
				//load a map fragment directly from the API
				fragment = new SupportMapFragment ();

				break;
			case 1:
				//load a fragment with a frame layout, create a SupportMapFragment,
				//and insert it into the frame layout
				fragment = new MyMapFragment ();
				break;
			case 2:
				//load a fragment with a map fragment defined in the layout
				fragment = new MyMapFragment2 ();
				break;
			case 3:
				//example of map in a fragment sharing screen space with other controls
				fragment = new MyMapFragment3 ();
				break;
			default:

				break;
			}

			// Insert the fragment by replacing any existing fragment
			SupportFragmentManager.BeginTransaction ()
				.Replace (Resource.Id.content_frame, fragment)
				.Commit ();

			// Highlight the selected item, update the title, and close the drawer
			drawerList.SetItemChecked (position, true);
			SupportActionBar.Title = sections [position];
			drawerLayout.CloseDrawer (drawerList);
		}