protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); layoutTabSelectors = FindViewById <LinearLayout>(Resource.Id.layoutTabSelectors); selectorCurrentValuesTab = FindViewById <LinearLayout>(Resource.Id.selectorCurrentValuesTab); selectorDeviceInfoTab = FindViewById <LinearLayout>(Resource.Id.selectorDeviceInfoTab); layoutTabs = FindViewById <LinearLayout>(Resource.Id.layoutTabs); buttonCurrentValuesTab = FindViewById <Button>(Resource.Id.buttonCurrentValuesTab); buttonDeviceInfoTab = FindViewById <Button>(Resource.Id.buttonDeviceInfoTab); fabInfo = FindViewById <FloatingActionButton>(Resource.Id.fabInfo); selectedColor = new Color(ContextCompat.GetColor(this, Resource.Color.colorAccent)); notSelectedColor = new Color(ContextCompat.GetColor(this, Resource.Color.colorPrimary)); currentValuesFragment = new CurrentValuesFragment(); deviceInfoFragment = new DeviceInfoFragment(); InitControls(); }
private void ShowFragment(PartialType type) { var partialSetup = SupportFragmentManager.BeginTransaction(); if (type == PartialType.CurrentValues) { partialSetup.Hide(deviceInfoFragment); partialSetup.AddToBackStack(null); currentValuesFragment = new CurrentValuesFragment(); partialSetup.Replace(Resource.Id.fragmentContainer, currentValuesFragment, "CurrentValuesFragment"); partialSetup.Show(currentValuesFragment); } else if (type == PartialType.DeviceInfo) { partialSetup.Hide(currentValuesFragment); partialSetup.AddToBackStack(null); deviceInfoFragment = new DeviceInfoFragment(); partialSetup.Replace(Resource.Id.fragmentContainer, deviceInfoFragment, "DeviceInfoFragment"); partialSetup.Show(deviceInfoFragment); } if (!IsFinishing) { partialSetup.CommitAllowingStateLoss(); } }