@Override public void removeTab(TabProxy tabProxy) { int tabIndex = ((TabGroupProxy) proxy).getTabIndex(tabProxy); TabFragment fragment = (TabFragment) tabGroupPagerAdapter.getRegisteredFragment(tabIndex); TiUIActionBarTab tabView = (TiUIActionBarTab) tabProxy.peekView(); actionBar.removeTab(tabView.tab); if (fragment != null) { fragment.setTab(null); } tabGroupPagerAdapter.notifyDataSetChanged(); }
public void disableTabNavigation(boolean disable) { if (disable && actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS) { savedSwipeable = swipeable; swipeable = false; ActionBar.Tab tab = actionBar.getSelectedTab(); if (tab == null) { Log.e(TAG, "No selected tab when trying to disable Tab Navigation"); return; } TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag(); savedFragment = tabView.fragment; tabsDisabled = true; tabGroupPagerAdapter.notifyDataSetChanged(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } else if (!disable && actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD) { tabsDisabled = false; savedFragment = null; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tabGroupPagerAdapter.notifyDataSetChanged(); swipeable = savedSwipeable; } }
@Override public void addTab(TabProxy tabProxy) { ActionBar.Tab tab = actionBar.newTab(); tab.setTabListener(this); // Create a view for this tab proxy. TiUIActionBarTab actionBarTab = new TiUIActionBarTab(tabProxy, tab); tabProxy.setView(actionBarTab); // Add the new tab, but don't select it just yet. // The selected tab is set once the group is done opening. actionBar.addTab(tab, false); tabGroupPagerAdapter.notifyDataSetChanged(); int numTabs = actionBar.getTabCount(); int offscreen = numTabs > 1 ? numTabs - 1 : 1; // Must be at least 1 tabGroupViewPager.setOffscreenPageLimit(offscreen); }