Exemplo n.º 1
0
        /// <summary>
        /// 切换布局
        /// </summary>
        /// <param name="view">View.</param>
        public void switchFragment(View view)
        {
            int viewId = view.Id;

            changeTextStatus(viewId);
            Android.Support.V4.App.Fragment fragment = null;
            switch (viewId)
            {
            case Resource.Id.tv_teach:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new TeachFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;

            case Resource.Id.tv_mine:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new MineFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;

            case Resource.Id.tv_district:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    if (IsArea)
                    {
                        fragment = new DistrictMainFragment();
                    }
                    else
                    {
                        fragment = new NoPermissionFragment();
                    }
                    fragmentHashtable.Add(viewId, fragment);
                }


                break;

            default:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new IndexFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;
            }
            switchContent(lastFragment, fragment);
        }
Exemplo n.º 2
0
        protected override void InitViews()
        {
            mFrameLayout = (FrameLayout)FindViewById(Resource.Id.fl_content);
            tv_index     = (TextView)FindViewById(Resource.Id.tv_index);
            tv_teach     = (TextView)FindViewById(Resource.Id.tv_teach);
            tv_mine      = (TextView)FindViewById(Resource.Id.tv_mine);
            tv_district  = (TextView)FindViewById(Resource.Id.tv_district);

            Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();

            #region 区域权限判断
            var type = CurrUserInfo.Type;
            if (type == (int)UserType.DataManager ||
                type == (int)UserType.AreaManager ||
                type == (int)UserType.AreaSuperManager ||
                type == (int)UserType.ShopManager)
            {
                IsArea = true;
            }
            #endregion

            int p_index = Intent.GetIntExtra("p_index", 0);
            if (p_index == 1)
            {
                TeachFragment fragment = new TeachFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_teach, fragment);
            }
            else if (p_index == 2)
            {
                MineFragment fragment = new MineFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_mine, fragment);
            }
            else if (p_index == 3)
            {
                if (IsArea)
                {
                    DistrictMainFragment fragment = new DistrictMainFragment();
                    lastFragment = fragment;
                    transaction.Replace(Resource.Id.fl_content, fragment);
                    fragmentHashtable.Add(Resource.Id.tv_district, fragment);
                }
                else
                {
                    NoPermissionFragment fragment = new NoPermissionFragment();
                    lastFragment = fragment;
                    transaction.Replace(Resource.Id.fl_content, fragment);
                    fragmentHashtable.Add(Resource.Id.tv_district, fragment);
                }
            }
            else
            {
                IndexFragment fragment = new IndexFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_index, fragment);
            }

            transaction.Commit();
        }
Exemplo n.º 3
0
        void SwicthFragment(int id)
        {
            FragmentTransaction ft = fragmentManager.BeginTransaction();

            HideAllFragment(ft);
            switch (id)
            {
            case Resource.Id.navigation_home:
                if (indexFragment == null)
                {
                    indexFragment = new IndexFragment();
                    ft.Add(Resource.Id.flyout_, indexFragment);
                }
                else
                {
                    ft.Show(indexFragment);
                }
                SetToolbarTitle(Resources.GetString(Resource.String.toolbar_title_index));
                break;

            case Resource.Id.navigation_dashboard:
                if (newsFragment == null)
                {
                    newsFragment = new NewsFragment();
                    ft.Add(Resource.Id.flyout_, newsFragment);
                }
                else
                {
                    ft.Show(newsFragment);
                }
                SetToolbarTitle(Resources.GetString(Resource.String.toolbar_title_news));
                break;

            case Resource.Id.navigation_notifications:
                if (TalkFragment == null)
                {
                    TalkFragment = new TalkFragment();
                    ft.Add(Resource.Id.flyout_, TalkFragment);
                }
                else
                {
                    ft.Show(TalkFragment);
                }
                SetToolbarTitle(Resources.GetString(Resource.String.toolbar_title_question));
                break;

            case Resource.Id.navigation_question:
                if (questionFragment == null)
                {
                    questionFragment = new QuestionFragment(false);
                    ft.Add(Resource.Id.flyout_, questionFragment);
                }
                else
                {
                    ft.Show(questionFragment);
                }
                SetToolbarTitle(Resources.GetString(Resource.String.title_question));
                break;

            case Resource.Id.navigation_mine:
                if (mineFragment == null)
                {
                    mineFragment = new MineFragment();
                    ft.Add(Resource.Id.flyout_, mineFragment);
                }
                else
                {
                    ft.Show(mineFragment);
                }
                break;
            }
            ft.Commit();
        }