public static TopSongsFragment NewInstance(int playId)
        {
            var topsongsFrag = new TopSongsFragment {
                Arguments = new Bundle()
            };

            topsongsFrag.Arguments.PutInt("current_play_id", playId);
            return(topsongsFrag);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            base.OnCreate(savedInstanceState);
            var index = Intent.Extras.GetInt("current_play_id", 0);
            //SongDB mySongDB = Intent.GetObject<SongDB>()
            //new Intent(this, typeof(Activity2));
            //activity2.PutExtra("MyData", "Data from Activity1");

            var topsongs            = TopSongsFragment.NewInstance(index); // DetailsFragment.NewInstance is a factory method to create a Details Fragment
            var fragmentTransaction = FragmentManager.BeginTransaction();

            fragmentTransaction.Add(Android.Resource.Id.Content, topsongs);
            fragmentTransaction.Commit();
        }
Example #3
0
        private void ShowTopSongs(int playId)
        {
            _currentPlayId = playId;
            if (_isDualPane)
            {
                // We can display everything in-place with fragments.
                // Have the list highlight this item and show the data.
                ListView.SetItemChecked(playId, true);

                // Check what fragment is shown, replace if needed.
                var topsongs = FragmentManager.FindFragmentById(Resource.Id.topsongs) as TopSongsFragment;
                if (topsongs == null || topsongs.ShownPlayId != playId)
                {
                    // Make new fragment to show this selection.
                    topsongs = TopSongsFragment.NewInstance(playId);

                    // Execute a transaction, replacing any existing
                    // fragment with this one inside the frame.
                    var ft = FragmentManager.BeginTransaction();
                    ft.Replace(Resource.Id.topsongs, topsongs);
                    ft.SetTransition(FragmentTransit.FragmentFade);
                    ft.Commit();
                }
            }
            else
            {
                // Otherwise we need to launch a new activity to display
                // the dialog fragment with selected text.
                var intent = new Intent();

                intent.SetClass(Activity, typeof(TopSongsActivity));
                intent.PutExtra("current_play_id", playId);
                //intent.PutExtra("current_songdb", mySongDB);

                StartActivity(intent);
            }
        }