Beispiel #1
0
        private void LoadFragment(int id)
        {
            Fragment fragment = null;

            switch (id)
            {
            case Resource.Id.menu_home:
                fragment = HomeFragment.NewInstance();
                break;

            case Resource.Id.menu_library:
                fragment = LibraryFragment.NewInstance();
                break;

            case Resource.Id.menu_search:
                fragment = SearchFragment.NewInstance();
                break;

            case Resource.Id.menu_menu:
                fragment = MenuFragment.NewInstance();
                break;
            }

            if (fragment == null)
            {
                return;
            }

            FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
        }
        private void SetupContainerFragments()
        {
            taskFrame = FindViewById <FrameLayout>(Resource.Id.content_frame_task);
            chatFrame = FindViewById <FrameLayout>(Resource.Id.content_frame_chat);
            menuFrame = FindViewById <FrameLayout>(Resource.Id.content_frame_menu);

            //task
            var fragmentTxHome = SupportFragmentManager.BeginTransaction();

            TaskFragment             = TaskFragment.NewInstance();
            TaskFragment.DataContext = ViewModel.TaskViewModel;
            fragmentTxHome.Replace(Resource.Id.content_frame_task, TaskFragment);
            fragmentTxHome.Commit();

            //chat
            var fragmentTxChat = SupportFragmentManager.BeginTransaction();

            ChatFragment             = ChatHistoryFragment.NewInstance();
            ChatFragment.DataContext = ViewModel.ChatViewModel;
            fragmentTxChat.Replace(Resource.Id.content_frame_chat, ChatFragment);
            fragmentTxChat.Commit();

            //menu
            var fragmentTxMenu = SupportFragmentManager.BeginTransaction();

            MenuFragment             = MenuFragment.NewInstance();
            MenuFragment.DataContext = ViewModel.MenuViewModel;
            fragmentTxMenu.Replace(Resource.Id.content_frame_menu, MenuFragment);
            fragmentTxMenu.Commit();
        }