/// <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);
            }
        }
Exemplo n.º 2
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();
        }