コード例 #1
0
        protected void InitViews(View view)
        {
            mFrameLayout = view.FindViewById <FrameLayout>(Resource.Id.fl_district_content);
            tv_budge     = view.FindViewById <TextView>(Resource.Id.tv_budge);
            tv_sum       = view.FindViewById <TextView>(Resource.Id.tv_sum);
            tv_increase  = view.FindViewById <TextView>(Resource.Id.tv_increase);
            tv_new       = view.FindViewById <TextView>(Resource.Id.tv_new);
            tv_dataType  = view.FindViewById <TextView>(Resource.Id.tv_datatype);

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

            int p_index = CurrActivity.Intent.GetIntExtra("p_index", 0);

            //预算
            if (p_index == 0)
            {
                BudgeFragment fragment = new BudgeFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_district_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_budge, fragment);

                TitleType = 1;
            }
            //累计
            else if (p_index == 1)
            {
                SumAccountFragment fragment = new SumAccountFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_district_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_sum, fragment);

                TitleType = 2;
            }
            //增量
            else if (p_index == 2)
            {
                IncreaseFragment fragment = new IncreaseFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_district_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_increase, fragment);
            }
            //招新
            else if (p_index == 3)
            {
                NewStudentFragment fragment = new NewStudentFragment();
                lastFragment = fragment;
                transaction.Replace(Resource.Id.fl_district_content, fragment);
                fragmentHashtable.Add(Resource.Id.tv_new, fragment);

                TitleType = 3;
            }


            transaction.Commit();
        }
コード例 #2
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_budge:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new BudgeFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;

            //累计
            case Resource.Id.tv_sum:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new SumAccountFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;

            //增量
            case Resource.Id.tv_increase:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new IncreaseFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;

            //招新
            case Resource.Id.tv_new:
                fragment = (Android.Support.V4.App.Fragment)fragmentHashtable[viewId];
                if (fragment == null)
                {
                    fragment = new NewStudentFragment();
                    fragmentHashtable.Add(viewId, fragment);
                }
                break;
            }
            switchContent(lastFragment, fragment);
        }