Beispiel #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);
        }
Beispiel #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();
        }