protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.ActivityMain); bool mMessage = Intent.GetBooleanExtra("ismessage", false); string mRef = Intent.GetStringExtra("ref"); string mRefListMod = Intent.GetStringExtra("reflistmod"); string mName = Intent.GetStringExtra("name"); //Переменные объектов активити mToolbar = FindViewById <SupportToolbar>(Resource.Id.Toolbar); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.DrawerLayout); mLeftDrawer = FindViewById <ListView>(Resource.Id.mainLeftDrawer); mRightDrawer = FindViewById <ListView>(Resource.Id.mainRightDrawer); mTextViewLogin = FindViewById <TextView>(Resource.Id.mainTextViewLogin); mButtonLogout = FindViewById <Button>(Resource.Id.btnLogout); mSwipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.mainSwipeLayout); mSwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueBright, Android.Resource.Color.HoloBlueDark, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloRedLight); mSwipeRefreshLayout.Refresh += MSwipeRefreshLayout_Refresh; mTextViewLogin.Text = AppVariable.Variable.Login; mButtonLogout.Click += MButtonLogout_Click; //Классы фрагментов Fragment = new FragmentMain(); messagesFragment = new FragmentMessages(); tasksFragment = new FragmentElements(); directoriesFragment = new FragmentElements(); docsFragment = new FragmentElements(); ReportsFragment = new FragmentElements() { isReport = true }; DataProcessorsFragment = new FragmentElements() { isReport = true }; mStackFragments = new Stack <SupportFragment>(); mLeftDrawer.Tag = 0; mRightDrawer.Tag = 1; mToolbar.Title = mMessage ? "Сообщения" : "Главная страница"; SetSupportActionBar(mToolbar); UpdateLeftDrawer(); mLeftDrawer.ItemClick += MenuListView_ItemClick; mRightDataSet = new List <string>(); mRightDataSet.Add("Справка"); mRightDataSet.Add("О программе"); if (AppVariable.Variable.DebugMode) { mRightDataSet.Add("Форма для тестирования"); } mRightAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mRightDataSet); mRightDrawer.Adapter = mRightAdapter; mRightDrawer.ItemClick += MRightDrawer_ItemClick; mDrawerToggle = new UIActionBarDrawerToggle(this, mDrawerLayout); mDrawerLayout.AddDrawerListener(mDrawerToggle); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); mDrawerToggle.SyncState(); Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction(); tx.Add(Resource.Id.FragmentLayout, Fragment); tx.Add(Resource.Id.FragmentLayout, messagesFragment); tx.Add(Resource.Id.FragmentLayout, tasksFragment); tx.Add(Resource.Id.FragmentLayout, directoriesFragment); tx.Add(Resource.Id.FragmentLayout, docsFragment); tx.Add(Resource.Id.FragmentLayout, ReportsFragment); tx.Add(Resource.Id.FragmentLayout, DataProcessorsFragment); tx.Hide(mMessage ? (SupportFragment)Fragment : (SupportFragment)messagesFragment); tx.Hide(tasksFragment); tx.Hide(directoriesFragment); tx.Hide(docsFragment); tx.Hide(ReportsFragment); tx.Hide(DataProcessorsFragment); mCurrentFragment = mMessage ? (SupportFragment)messagesFragment : (SupportFragment)Fragment; tx.Commit(); if (mRef != null && mRefListMod != null) { Intent intent = new Intent(this, typeof(ActivityDataView)); intent.PutExtra("reflistmod", mRefListMod); intent.PutExtra("ref", mRef); intent.PutExtra("name", mName); StartActivity(intent); } }
public static Android.Support.V4.App.Fragment newInstance(Context context) { FragmentMessages busrouteFragment = new FragmentMessages(); return(busrouteFragment); }