protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.fragment_menu); var fm = SupportFragmentManager; var ft = fm.BeginTransaction(); fragment1 = fm.FindFragmentByTag("f1"); if(fragment1 == null) { fragment1 = new MenuFragment(); ft.Add (fragment1, "f1"); } fragment2 = fm.FindFragmentByTag("f2"); if (fragment2 == null) { fragment2 = new Menu2Fragment(); ft.Add(fragment2, "f2"); } ft.Commit(); // Watch check box clicks. checkBox1 = FindViewById<CheckBox>(Resource.Id.menu1); checkBox1.Click += HandleCheckBoxClick; checkBox2 = FindViewById<CheckBox>(Resource.Id.menu2); checkBox2.Click += HandleCheckBoxClick; // Make sure fragments start out with correct visibility. UpdateFragmentVisibility(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.main); var fragments = new Fragment[] { new PeopleFragment(), new FilmsFragment(), new StarshipsFragment(), new VehiclesFragment(), new SpeciesFragment(), new PlanetsFragment() }; var titles = CharSequence.ArrayFromStringArray(new[] { "People", "Films", "Starships", "Vehicles", "Species", "Planets" }); var viewPager = FindViewById<ViewPager>(Resource.Id.viewpager); viewPager.Adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, fragments, titles); // Give the TabLayout the ViewPager var tabLayout = FindViewById<TabLayout>(Resource.Id.sliding_tabs); tabLayout.SetupWithViewPager(viewPager); }
//@Override protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // set the Above View if (savedInstanceState != null) mContent = SupportFragmentManager.GetFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new ColorFragment(Resource.Color.red); // set the Above View SetContentView(Resource.Layout.content_frame); SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.content_frame, mContent) .Commit(); // set the Behind View setBehindContentView(Resource.Layout.menu_frame); SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.menu_frame, new ColorMenuFragment()) .Commit(); // customize the SlidingMenu getSlidingMenu().setTouchModeAbove(SSlidingMenu.TOUCHMODE_FULLSCREEN); }
public static FragmentComponent GetComponent(Fragment fragment) { var activity = (AppCompatActivity) fragment.Activity; var application = (MainApplication)fragment.Context.ApplicationContext; return application.appComponent .Plus(new ActivityModule(activity)) .Plus(new FragmentModule(fragment)); }
//@Override protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetTitle(Resource.String.responsive_ui); SetContentView(Resource.Layout.responsive_content_frame); // check if the content frame contains the menu frame if (FindViewById(Resource.Id.menu_frame) == null) { setBehindContentView(Resource.Layout.menu_frame); getSlidingMenu().setSlidingEnabled(true); getSlidingMenu().setTouchModeAbove(SSlidingMenu.TOUCHMODE_FULLSCREEN); // show home as up so we can toggle SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true); } else { // add a dummy view View v = new View(this); setBehindContentView(v); getSlidingMenu().setSlidingEnabled(false); getSlidingMenu().setTouchModeAbove(SSlidingMenu.TOUCHMODE_NONE); } // set the Above View Fragment if (savedInstanceState != null) mContent = SupportFragmentManager.GetFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new BirdGridFragment(0); SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.content_frame, mContent) .Commit(); // set the Behind View Fragment SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.menu_frame, new BirdMenuFragment()) .Commit(); // customize the SlidingMenu SSlidingMenu sm = getSlidingMenu(); sm.setBehindOffsetRes(Resource.Dimension.slidingmenu_offset); sm.setShadowWidthRes(Resource.Dimension.shadow_width); sm.setShadowDrawable(Resource.Drawable.shadow); sm.setBehindScrollScale(0.25f); sm.setFadeDegree(0.25f); // show the explanation dialog if (savedInstanceState == null) new AlertDialog.Builder(this) .SetTitle(Resource.String.what_is_this) .SetMessage(Resource.String.responsive_explanation) .Show(); }
public void switchContent(Android.Support.V4.App.Fragment fragment) { mContent = fragment; SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); getSlidingMenu().showContent(); }
public override Android.Support.V4.App.Fragment GetItem(int position) { switch (position) { case 0: fragment = new MyKomuniti_Tab_1(); break; case 1: fragment = new MyKomuniti_Tab_2(); break; } return fragment; }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.activity_singlepane_empty); ActivityHelper.SetupActionBar (new Java.Lang.String (Title), new Color (0)); var customTitle = Intent.GetStringExtra (Intent.ExtraTitle); var title = new Java.Lang.String (customTitle != null ? customTitle : Title); ActivityHelper.SetActionBarTitle (title); if (savedInstanceState == null) { fragment = OnCreatePane (); fragment.Arguments = IntentToFragmentArguments (Intent); SupportFragmentManager.BeginTransaction ().Add (Resource.Id.root_container, fragment).Commit (); } }
public override Android.Support.V4.App.Fragment GetItem(int position) { Android.Support.V4.App.Fragment fr = new Android.Support.V4.App.Fragment(); switch (position) { case 0: fr = new FirstFragment(); break; case 1: fr = new SecondFragment(); break; case 2: fr = new ThirdFragment(); break; case 3: fr = new FourthFragment(); break; } return fr; }
public void OnTabSelected(SherlockActionBar.Tab tab, FragmentTransaction transaction) { DebugHelper.WriteDebugEntry("In IntroActivity OnTabSelected(): " + tab.Tag); _currentTabTag = (String)tab.Tag; switch (_currentTabTag) { case "track": RenderTrackItTabFragment(transaction); break; case "report": if (_reportFragment == null) { _reportFragment = new ReportCrueltyFragment(); transaction.Add(Resource.Id.fragmentContainer, _reportFragment, "report"); } else { transaction.Show(_reportFragment); } if (_listToggleButton != null) { _listToggleButton.Visibility = ViewStates.Gone; } break; } }
public ImagePagerAdapter(Android.Support.V4.App.FragmentManager fm, Resources resources) : base(fm) { mResources = resources; listFragment = new ImageListFragment(); gridFragment = new ImageGridFragment(); }
/// <summary> /// Show Fragment with a specific tag at a specific placeholder /// </summary> /// <param name="tag">The tag for the fragment to lookup</param> /// <param name="contentId">Where you want to show the Fragment</param> /// <param name="bundle">Bundle which usually contains a Serialized MvxViewModelRequest</param> /// <param name="forceAddToBackStack">If you want to force add the fragment to the backstack so on backbutton it will go back to it. Note: This will override IMvxCachedFragmentInfo.AddToBackStack configuration.</param> /// <param name="forceReplaceFragment">If you want the fragment to be re-created</param> protected virtual void ShowFragment(string tag, int contentId, Bundle bundle, bool forceAddToBackStack = false, bool forceReplaceFragment = false) { IMvxCachedFragmentInfo fragInfo; FragmentCacheConfiguration.TryGetValue(tag, out fragInfo); IMvxCachedFragmentInfo currentFragInfo = null; var currentFragment = SupportFragmentManager.FindFragmentById(contentId); if (currentFragment != null) { FragmentCacheConfiguration.TryGetValue(currentFragment.Tag, out currentFragInfo); } if (fragInfo == null) { throw new MvxException("Could not find tag: {0} in cache, you need to register it first.", tag); } // We shouldn't replace the current fragment unless we really need to. FragmentReplaceMode fragmentReplaceMode = FragmentReplaceMode.ReplaceFragmentAndViewModel; if (!forceReplaceFragment) { fragmentReplaceMode = ShouldReplaceCurrentFragment(fragInfo, currentFragInfo, bundle); } if (fragmentReplaceMode == FragmentReplaceMode.NoReplace) { return; } var ft = SupportFragmentManager.BeginTransaction(); OnBeforeFragmentChanging(fragInfo, ft); fragInfo.ContentId = contentId; //If we already have a previously created fragment, we only need to send the new parameters if (fragInfo.CachedFragment != null && fragmentReplaceMode == FragmentReplaceMode.ReplaceFragment) { ((Fragment)fragInfo.CachedFragment).Arguments.Clear(); ((Fragment)fragInfo.CachedFragment).Arguments.PutAll(bundle); } else { //Otherwise, create one and cache it fragInfo.CachedFragment = Fragment.Instantiate(this, FragmentJavaName(fragInfo.FragmentType), bundle) as IMvxFragmentView; OnFragmentCreated(fragInfo, ft); } currentFragment = fragInfo.CachedFragment as Fragment; ft.Replace(fragInfo.ContentId, fragInfo.CachedFragment as Fragment, fragInfo.Tag); //if replacing ViewModel then clear the cache after the fragment //has been added to the transaction so that the Tag property is not null //and the UniqueImmutableCacheTag property (if not overridden) has the correct value if (fragmentReplaceMode == FragmentReplaceMode.ReplaceFragmentAndViewModel) { var cache = Mvx.GetSingleton <IMvxMultipleViewModelCache>(); cache.GetAndClear(fragInfo.ViewModelType, GetTagFromFragment(fragInfo.CachedFragment as Fragment)); } if ((currentFragment != null && fragInfo.AddToBackStack) || forceAddToBackStack) { ft.AddToBackStack(fragInfo.Tag); } OnFragmentChanging(fragInfo, ft); ft.Commit(); SupportFragmentManager.ExecutePendingTransactions(); OnFragmentChanged(fragInfo); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.fragmentHolder); btnNext = FindViewById <ImageButton>(Resource.Id.btnContinueFragment); btnBack = FindViewById <ImageButton>(Resource.Id.btnBackFragment); var mFrg1 = new P_IFR_Dual_Local3(); var mFrg2 = new P_IFR_Dual_Local4(); mStackFragment = new Stack <SupportFragment>(); var trans = SupportFragmentManager.BeginTransaction(); if (questionNum == 5) { mCurrent = mFrg2; questionNum = 3; } else { questionNum = 0; mCurrent = mFrg1; } trans.Add(Resource.Id.frameLayout1, mCurrent); trans.Commit(); Bundle bundle = new Bundle();; Android.App.FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction(); mFrg2.Arguments = bundle; mFrg1.Arguments = bundle; var txtRisk = FindViewById <TextView>(Resource.Id.txtRiskFragment); var txtRiskNum = FindViewById <TextView>(Resource.Id.txtRiskNumFragment); ShortCutFunctions sc = new ShortCutFunctions(); sc.riskShow(txtRisk, txtRiskNum, "Alternate Risk", altRisk, 9, 12); btnNext.Click += (s, e) => { if (mCurrent.Equals(mFrg2)) //determining question { if (altRisk > 11) { sc.alertShow("Alternate Risk", this); } else { StartActivity(typeof(Y_Aircraft_and_Instructor)); questionNum = 5; } } else { questionNum += 2; replaceFragment(mFrg2); } }; btnBack.Click += (s, e) => { if (mCurrent.Equals(mFrg1)) { StartActivity(typeof(P_IFR_Dual_Local_3DayNight)); } else { replaceFragment(mFrg1); questionNum -= 2; } }; }
public void AddFragment(Fragment fragment, String title) { fragments.Add(fragment); fragmentTitles.Add(title); }
public static IViewModelStore GetViewModelStore(this Fragment owner) { return(ViewModelStoreFragment.FindOrCreate(owner)); }
public void Add(string title, Fragment fragment) { items.Add(new KeyValuePair <string, Fragment> (title, fragment)); }
public void AddTab(TabType title, Android.Support.V4.App.Fragment frag) { Titles.Add(title); fragments.Add(frag); NotifyDataSetChanged(); }
public void UpdateContent(Uri uri) { Fragment fragment; string tag; FragmentManager fm = SupportFragmentManager; FragmentTransaction tr = fm.BeginTransaction(); if (CurrentContentFragmentTag != null) { Fragment currentFragment = fm.FindFragmentByTag(CurrentContentFragmentTag); if (currentFragment != null) { tr.Hide(currentFragment); } } if (AboutFragment.ABOUT_URI.Equals(uri)) { tag = AboutFragment.TAG; Fragment foundFragment = fm.FindFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new AboutFragment(); } } else if (SandboxFragment.SETTINGS_URI.Equals(uri)) { tag = SandboxFragment.TAG; SandboxFragment foundFragment = (SandboxFragment)fm.FindFragmentByTag(tag); if (foundFragment != null) { foundFragment.OnSettingsChangedListener = mSettingsChangedListener; fragment = foundFragment; } else { SandboxFragment settingsFragment = new SandboxFragment(); settingsFragment.OnSettingsChangedListener = mSettingsChangedListener; fragment = settingsFragment; } } else if (uri != null) { tag = WebViewFragment.TAG; WebViewFragment webViewFragment; Fragment foundFragment = fm.FindFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; webViewFragment = (WebViewFragment)fragment; } else { webViewFragment = new WebViewFragment(); fragment = webViewFragment; } webViewFragment.Url = uri.ToString(); } else { return; } if (fragment.IsAdded) { tr.Show(fragment); } else { tr.Add(Resource.Id.content, fragment, tag); } tr.Commit(); CurrentUri = uri; CurrentContentFragmentTag = tag; }
private void InditialFragment() { testsTab = new Android.Support.V4.App.Fragment(); profilesTab = new SettingsFragment(); articlesTab = new RegistrationTypeFragment(); }
public void addFragment(Android.Support.V4.App.Fragment fragment, string title) { mFragmentList.Add(fragment); mFragmentTitleList.Add(title); }
public void AddFragment(string title, Fragment fragment) { _fragments.Add(fragment); _titles.Add(title); }
public abstract void OnDestroyItem(int position, Android.Support.V4.App.Fragment fragment);
protected virtual string GetTagFromFragment(Fragment fragment) { var mvxFragmentView = fragment as IMvxFragmentView; // ReSharper disable once PossibleNullReferenceException // Fragment can never be null because registered fragment has to inherit from IMvxFragmentView return mvxFragmentView.UniqueImmutableCacheTag; }
public void AddFragment(Fragment fragment) { fragments.Add(fragment); NotifyDataSetChanged(); }
public override void OnFragmentDestroyed(FragmentManager fm, Fragment f) { base.OnFragmentDestroyed(fm, f); _pendingFragmentHolders.Remove(f); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _uiHelper = new UiLifecycleHelper(this, callback); _uiHelper.OnCreate(savedInstanceState); if (savedInstanceState != null) { string name = savedInstanceState.GetString(PENDING_ACTION_BUNDLE_KEY); _pendingAction = (PendingAction)Enum.Parse(typeof(PendingAction), name); } SetContentView(Resource.Layout.FacebookScreen); //_googlePlayLink = "http://play.google.com/store/apps/details?id=" + this.PackageName; _ID = Intent.GetIntExtra("ID", 0); _Item = MainActivity._BDDB.SelectItem(_ID); TimeSpan ts = _Item._EndDate.Subtract(DateTime.Now); string DaysTo = String.Format("{0:0000}", ts.Days); string HoursTo = String.Format("{0:00}", ts.Hours); string MinTo = String.Format("{0:00}", ts.Minutes); string SecTo = String.Format("{0:00}", ts.Seconds); _message = string.Format("{0} {1} {2} days, {3} hours, {4} minutes, {5} seconds {6}", _Item._Name, _Item._EndDate < DateTime.Now ? "was" : "is coming in", DaysTo, HoursTo, MinTo, SecTo, _Item._EndDate < DateTime.Now ? " ago" : ""); _textFacebookDescription = (TextView)FindViewById(Resource.Id.textFacebookDescription); _textFacebookDescription.Text = _message; _textMessage = (EditText)FindViewById(Resource.Id.txtMessage); _loginButton = (LoginButton)FindViewById(Resource.Id.facebook_login_button); _loginButton.UserInfoChangedCallback = new MyUserInfoChangedCallback(this); _postStatusUpdateButton = FindViewById <Button> (Resource.Id.postStatusUpdateButton); _postStatusUpdateButton.Click += delegate { OnClickPostStatusUpdate(); }; _controlsContainer = (ViewGroup)FindViewById(Resource.Id.main_ui_container); Android.Support.V4.App.FragmentManager fm = SupportFragmentManager; Android.Support.V4.App.Fragment fragment = fm.FindFragmentById(Resource.Id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. _controlsContainer.Visibility = ViewStates.Gone; } fm.BackStackChanged += delegate { if (fm.BackStackEntryCount == 0) { // We need to re-show our UI. _controlsContainer.Visibility = ViewStates.Visible; } }; }
public MapBaseBottomLayoutAdapter(Android.Support.V4.App.FragmentManager fm, Android.Support.V4.App.Fragment modeMetaDataFragment, MapViewModelBase maBase) : base(fm) { _modeMetaDataFragment = modeMetaDataFragment; _locationHistoryFragment = new LocationHistoryFragment(maBase); }
public void SetFrActivity(Android.Support.V4.App.Fragment FrActivity) { this.activity = FrActivity; }
public TabsFragmentPagerAdapter(FragmentManager fm, Fragment[] fragments, ICharSequence[] titles) : base(fm) { this._fragments = fragments; this._titles = titles; }
public override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetTheme(PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).GetInt("ThemeStyle", Resource.Style.Theme_Sherlock)); RequestWindowFeature(WindowFeatures.ActionBar); SetSlidingActionBarEnabled(true); // Left menu if (PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).GetBoolean("notesReplace", false)) { leftMenuFragment = new NotesFragment(); rightMenuFragment = new MenuFragmentAdvanced(); } else { leftMenuFragment = new MenuFragmentAdvanced(); rightMenuFragment = new NotesFragment(); } SetContentView(Resource.Layout.ViewPagerLayout); // Setup the left menu SetBehindContentView(Resource.Layout.MenuFrame); SupportFragmentManager.BeginTransaction().Replace(Resource.Id.MenuFrame, leftMenuFragment).Commit(); // Setup the right menu SlidingMenu.SetSecondaryMenu(Resource.Layout.MenuFrameSecondary); SupportFragmentManager.BeginTransaction().Replace(Resource.Id.MenuFrameSecondary, rightMenuFragment).Commit(); // Get display dimensions of current oriented screen Display display = WindowManager.DefaultDisplay; Android.Util.DisplayMetrics metrics = new Android.Util.DisplayMetrics(); display.GetMetrics(metrics); int width = (int)(metrics.WidthPixels * .333); // Setup the sliding menu SlidingMenu.Mode = SlidingMenuBinding.Lib.SlidingMenu.LeftRight; SlidingMenu.SetShadowWidthRes(Resource.Dimension.SlidingMenuShadowWidth); SlidingMenu.SetShadowDrawable(Resource.Drawable.SlidingMenuShadow); SlidingMenu.SetBehindWidth(width * 2); SlidingMenu.SetFadeDegree(0.35f); SlidingMenu.TouchModeAbove = SlidingMenuBinding.Lib.SlidingMenu.TouchmodeMargin; // Enable this so that we can toggle the menu when clicking the action bar home button in `OnOptionsItemSelected` SupportActionBar.SetDisplayHomeAsUpEnabled(true); InitializeView(); ThisApp.LanguageChanged += ThisApp_LanguageChanged; }
public Page(Android.Support.V4.App.Fragment fragment, string title) { m_fragment = fragment; m_title = title; }
private void ChangeFragments(int position) { fragment = CreateNewFragment(position); SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit(); }
private void OpenFragment (Fragment fragment) { var old = FragmentManager.FindFragmentById (Resource.Id.ContentFrameLayout); if (old == null) { FragmentManager.BeginTransaction () .Add (Resource.Id.ContentFrameLayout, fragment) .Commit (); } else if (old != fragment) { // The detach/attach is a workaround for https://code.google.com/p/android/issues/detail?id=42601 FragmentManager.BeginTransaction () .Detach (old) .Replace (Resource.Id.ContentFrameLayout, fragment) .Attach (fragment) .Commit (); } }
private void ListItemClicked(int position) { Android.Support.V4.App.Fragment fragment = null; string Tag = ""; switch (position) { case 0: //Console.WriteLine ("Canvass clickkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); fragment = new CanvassesFragment(); Tag = "canvassesFragment"; SupportFragmentManager.PopBackStack(); // try { // Console.WriteLine (" checking"); // Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction (); // Console.WriteLine (" Fragments found"+SupportFragmentManager.Fragments.Count); // foreach (var item in SupportFragmentManager.Fragments) { // Console.WriteLine (" item"+item.ToString()); // if (item.IsAdded) { // Console.WriteLine ("Deattaching item"+item.ToString()); // ft.Detach (item); // Console.WriteLine ("done item"+item.ToString()); // } // // } // ft.Add(Resource.Id.content_frame, new CanvassesFragment(), "canvassesFragment"); // // ft.AddToBackStack (null); // ft.Commit (); // } catch (Exception ex) { // Console.WriteLine (" exception"+ex.Message); // } // break; case 1: fragment = new mapFragment(); SupportFragmentManager.PopBackStack(); Tag = "mapFragment"; break; case 2: fragment = new RegisterFragment(); SupportFragmentManager.PopBackStack(); Tag = "registerFragment"; break; case 3: fragment = new SettingsFragment(); SupportFragmentManager.PopBackStack(); Tag = "settingsFragment"; break; } try { SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment, Tag) .Commit(); } catch (Exception ex) { //Console.WriteLine ("Exception : " + ex.ToString()); } this.m_DrawerList.SetItemChecked(position, true); SupportActionBar.Title = this.m_Title = Sections[position]; this.m_Drawer.CloseDrawer(this.m_DrawerList); }
/** * Called just before a fragment replacement transaction is committed in response to an intent * being fired and substituted for a fragment. */ protected virtual void OnBeforeCommitReplaceFragment (FragmentManager fm, FragmentTransaction ft, Fragment fragment) { }
public TagFilterAdaptor(Fragment fragment) { tagList = new List <SelectableAnnotationTag>(); this.fragment = fragment; }
public void SetFragment(Fragment fragment) { int i = fragment is ContactListView ? 0 : (fragment is CalendarView ? 1 : 2); _tabs[i] = fragment; NotifyDataSetChanged(); }
public ContactsAdapter(Android.Support.V4.App.Fragment activity) { _activity = activity; FillContacts(); }
private void ChangeFragment(Fragment targetFragment) { ResideMenu.ClearIgnoredViewList(); SupportFragmentManager .BeginTransaction().AddToBackStack(null) .Replace(Resource.Id.main_fragment, targetFragment, "fragment") .SetTransitionStyle(global::Android.Support.V4.App.FragmentTransaction.TransitFragmentFade) .Commit(); }
public void AddFragment(Fragment fragment, string title) { this.fragments.Add(fragment); this.titles.Add(title); }
public void Add(string title, Fragment fragment) { items.Add (new KeyValuePair<string, Fragment> (title, fragment)); }
public void AddFragment(Android.Support.V4.App.Fragment fragment) { Items.Add(fragment); }
private void RenderTrackItTabFragment(FragmentTransaction transaction) { if (_isMapView) { if (_fightitFragment != null) { transaction.Hide(_fightitFragment); } InitMapFragment(); transaction.Show(_mapFragment); SetupMapIfNeeded(); } else { if (_mapFragment != null) { transaction.Hide(_mapFragment); } if (_fightitFragment == null) { _fightitFragment = new FightItFragment(); transaction.Add(Resource.Id.fragmentContainer, _fightitFragment, "fight"); } else { transaction.Show(_fightitFragment); } } if (_listToggleButton != null) { _listToggleButton.Text = _isMapView ? "List" : "Map"; _listToggleButton.Visibility = ViewStates.Visible; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var tlbMain = FindViewById <Toolbar>(Resource.Id.topToolbar); tlbMain.InflateMenu(Resource.Menu.maintoolbar); SetSupportActionBar(tlbMain); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetTitle(Resource.String.ApplicationName); var mapFrag = new MapFrag(); var listFrag = new ListFrag(); var fragments = new Fragment[] { listFrag, mapFrag }; var titles = Android.Runtime.CharSequence.ArrayFromStringArray(new[] { "Strikes", "Map", }); var viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); var adapter = new TabsFragmentPagerAdapter(SupportFragmentManager, fragments, titles); viewPager.Adapter = adapter; var tabLayout = FindViewById <TabLayout>(Resource.Id.tabs); tabLayout.SetupWithViewPager(viewPager); listFrag.Refreshed += delegate { mapFrag.MapReadyAction += delegate { mapFrag.AddMarkers(listFrag.StrikeList); }; }; mapFrag.MapReadyAction += delegate { listFrag.Refreshed += delegate { mapFrag.AddMarkers(listFrag.StrikeList); }; }; Selected = new Color(ContextCompat.GetColor(this, Resource.Color.selectedTab)); Deselected = new Color(ContextCompat.GetColor(this, Resource.Color.normalTab)); tabLayout.GetTabAt(0).SetIcon(Resource.Drawable.ic_list_white_24dp); tabLayout.GetTabAt(1).SetIcon(Resource.Drawable.ic_map_white_24dp); UpdateTabs(viewPager.CurrentItem, tabLayout, tlbMain, adapter); viewPager.PageSelected += (sender, args) => { UpdateTabs(args.Position, tabLayout, tlbMain, adapter); }; }
public void AddFragment(Fragment fragment) { fragments.Add (fragment); NotifyDataSetChanged (); }
public void AddFragment(SupportFragment fragment, string name) { Fragments.Add(fragment); FragmentNames.Add(name); }
public void AddFragment(Android.Support.V4.App.Fragment fragment, string name) { Fragments.Add(fragment); FragmentNames.Add(name); }
public void switchContent(Android.Support.V4.App.Fragment fragment) { mContent = fragment; SupportFragmentManager .BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); Handler h = new Handler(); //h.postDelayed(new Runnable() { // public void run() { // getSlidingMenu().showContent(); // } //}, 50); }