コード例 #1
0
		/// <summary>
		/// Creates a new fragment instance to display the bios
		/// of the selected username from the nearby user list.
		/// </summary>
		/// <param name="userId">Index of the current selected username</param>
		/// <param name="bios">Array of all the nearby users' bios</param>
        public static NearbyProfileFragment NewInstance(int userId, string[] bios)
        {
			nearbyBios = bios;
			var nearbyProfileFrag = new NearbyProfileFragment {Arguments = new Bundle()};
			nearbyProfileFrag.Arguments.PutInt("selected_user_id", userId);
            return nearbyProfileFrag;
        }
コード例 #2
0
        /// <summary>
        /// Shows the profile of the current userId that is passed
        /// </summary>
        /// <param name="userId">The index of the selected user</param>
        private void ShowProfile(int userId)
        {
            selectedUserId = userId;
            if (isDualPane)
            {
                // We can display everything in-place with fragments.
                // Have the list highlight this item and show the data.
                ListView.SetItemChecked(userId, true);

                // Check what fragment is shown, replace if needed.
                var nearbyProfile = FragmentManager.FindFragmentById(Resource.Id.UserProfile) as NearbyProfileFragment;
                if (nearbyProfile == null || nearbyProfile.ShownUserId != userId)
                {
                    // Make new fragment to show this selection.
                    nearbyProfile = NearbyProfileFragment.NewInstance(userId, nearbyBios);

                    // Execute a transaction, replacing any existing
                    // fragment with this one inside the frame.
                    var ft = FragmentManager.BeginTransaction();
                    ft.Replace(Resource.Id.UserProfile, nearbyProfile);
                    ft.SetTransition(FragmentTransaction.TransitFragmentFade);
                    ft.Commit();
                }
            }
            else
            {
                // Otherwise we need to launch a new activity to display
                // the nearby profile fragment with user data.
                var intent = new Intent();

                intent.SetClass(Activity, typeof(NearbyProfileActivity));
                intent.PutExtra("selected_user_id", userId);
                StartActivity(intent);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a new fragment instance to display the bios
        /// of the selected username from the nearby user list.
        /// </summary>
        /// <param name="userId">Index of the current selected username</param>
        /// <param name="bios">Array of all the nearby users' bios</param>
        public static NearbyProfileFragment NewInstance(int userId, string[] bios)
        {
            nearbyBios = bios;
            var nearbyProfileFrag = new NearbyProfileFragment {
                Arguments = new Bundle()
            };

            nearbyProfileFrag.Arguments.PutInt("selected_user_id", userId);
            return(nearbyProfileFrag);
        }
コード例 #4
0
        /// <summary>
        /// Code to execute when the activity is created
        /// </summary>
        /// <param name="bundle">Any additional information passed to the activity</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var index = Intent.Extras.GetInt("selected_user_id", 0);

            var nearbyProfile       = NearbyProfileFragment.NewInstance(index, null);       // Details
            var fragmentTransaction = SupportFragmentManager.BeginTransaction();

            fragmentTransaction.Add(Android.Resource.Id.Content, nearbyProfile);
            fragmentTransaction.Commit();
        }