public void removeTabAt(int position) { if (this.mTabScrollView != null) { int selectedTabPosition = this.mSelectedTab != null ? this.mSelectedTab.getPosition() : this.mSavedTabPosition; this.mTabScrollView.removeTabAt(position); TabImpl removedTab = (TabImpl) this.mTabs.remove(position); if (removedTab != null) { removedTab.setPosition(-1); } int newTabCount = this.mTabs.size(); for (int i = position; i < newTabCount; i++) { ((TabImpl) this.mTabs.get(i)).setPosition(i); } if (selectedTabPosition == position) { Tab tab; if (this.mTabs.isEmpty()) { tab = null; } else { TabImpl tabImpl = (TabImpl) this.mTabs.get(Math.max(0, position - 1)); } selectTab(tab); } } }
@SuppressWarnings("deprecation") private void setupTabs(){ ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); String title = getString(R.string.artist); Tab tab = actionBar.newTab() .setText(title) .setTabListener(new ActionBarTabListener<PlaceHolderFragment>( this, title, PlaceHolderFragment.class, PlaceHolderFragment.getBundle(title))); actionBar.addTab(tab); title = getString(R.string.album); tab = actionBar.newTab() .setText(R.string.album) .setTabListener(new ActionBarTabListener<PlaceHolderFragment>( this, "album", PlaceHolderFragment.class, PlaceHolderFragment.getBundle(title))); actionBar.addTab(tab); }
protected void configureTabs(final ActionBar actionBar, ViewPager viewPager) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { Tab newTab = actionBar.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this); actionBar.addTab(newTab); } }
private void performTabClick(Tab tab) { switch (tab.getPosition()) { case 0: if (spnAllStations != null) { spnAllStations.performClick(); } break; case 1: AnalyticsUtil.sendEvent(AnalyticsUtil.UI_ACTION, "click_tab_favourites", "station: " + Constants.SELECTED_STATION_NAME_VALUE); this.startActivityForResult(new Intent(this, FavouritesActivity.class), Constants.FROM_FAVOURITES); break; case 2: AnalyticsUtil.sendEvent(AnalyticsUtil.UI_ACTION, "click_musicBrowser", "station: " + Constants.SELECTED_STATION_NAME_VALUE); this.startActivity(new Intent(this, FileChooserActivity.class)); // Fragments // FragmentManager fm = getSupportFragmentManager(); // FileChooserFragment fileList = new FileChooserFragment(); // fm.beginTransaction().replace(android.R.id.content, fileList).commit(); break; default: break; } }
private void setActionBar() { actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // actionBar.setTitle(getResources().getString(R.string.str_title_contacts_manager)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); Tab contactsTab = actionBar.newTab(); contactsTab.setText(getString(R.string.str_contacts)); contactsTab.setTabListener(contactsTabListener); actionBar.addTab(contactsTab); Tab groupsTab = actionBar.newTab(); groupsTab.setText(getString(R.string.str_lists)); groupsTab.setTabListener(groupsTabListener); actionBar.addTab(groupsTab); }
/** * Configures the {@link ActionBar} to display navigation tabNames. * * @param actionBar the {@link ActionBar} to customize. * @param names the collection of tab names. * @param listener the {@link TabListener} to handle tab selection events. */ public static void configureTabNavigation(final ActionBar actionBar, final List<String> names, final TabListener listener) { if (listener == null) { throw new IllegalArgumentException("TabListener must be supplied"); } actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (final String name : names) { final Tab tab = actionBar.newTab(); tab.setTabListener(listener); tab.setText(name); actionBar.addTab(tab); } }
@Override public void onTabSelected(Tab tab, FragmentTransaction arg1) { viewPager.setCurrentItem(tab.getPosition()); // if (tab.getPosition() == TabPagerAdapter.FRIENDS_TAB) { // txtBottomHint.setText(R.string.select_a_friend); // } else { // String text = (userSearched.length() != 0) ? String.format( // getString(R.string.username_history), userSearched) // : getString(R.string.search_for_a_mal_friend); // txtBottomHint.setText(text); // } String text = (userSearched.length() != 0) ? String.format( getString(R.string.username_history), userSearched) : getString(R.string.search_for_a_mal_friend); txtBottomHint.setText(text); }
public Tab setCustomView(View view) { this.mCustomView = view; if (this.mPosition >= 0) { WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition); } return this; }
public Tab setIcon(Drawable icon) { this.mIcon = icon; if (this.mPosition >= 0) { WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition); } return this; }
public Tab setText(CharSequence text) { this.mText = text; if (this.mPosition >= 0) { WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition); } return this; }
public Tab setContentDescription(CharSequence contentDesc) { this.mContentDesc = contentDesc; if (this.mPosition >= 0) { WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition); } return this; }
public void setSelectedNavigationItem(int position) { switch (this.mDecorToolbar.getNavigationMode()) { case 1: this.mDecorToolbar.setDropdownSelectedPosition(position); return; case 2: selectTab((Tab) this.mTabs.get(position)); return; default: throw new IllegalStateException("setSelectedNavigationIndex not valid for current navigation mode"); } }
private void configureTab(Tab tab, int position) { TabImpl tabi = (TabImpl) tab; if (tabi.getCallback() == null) { throw new IllegalStateException("Action Bar Tab must have a Callback"); } tabi.setPosition(position); this.mTabs.add(position, tabi); int count = this.mTabs.size(); for (int i = position + 1; i < count; i++) { ((TabImpl) this.mTabs.get(i)).setPosition(i); } }
public void addTab(Tab tab, boolean setSelected) { ensureTabsExist(); this.mTabScrollView.addTab(tab, setSelected); configureTab(tab, this.mTabs.size()); if (setSelected) { selectTab(tab); } }
public void addTab(Tab tab, int position, boolean setSelected) { ensureTabsExist(); this.mTabScrollView.addTab(tab, position, setSelected); configureTab(tab, position); if (setSelected) { selectTab(tab); } }
public void selectTab(Tab tab) { int i = -1; if (getNavigationMode() != 2) { this.mSavedTabPosition = tab != null ? tab.getPosition() : -1; return; } FragmentTransaction trans; if (!(this.mActivity instanceof FragmentActivity) || this.mDecorToolbar.getViewGroup().isInEditMode()) { trans = null; } else { trans = ((FragmentActivity) this.mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack(); } if (this.mSelectedTab != tab) { ScrollingTabContainerView scrollingTabContainerView = this.mTabScrollView; if (tab != null) { i = tab.getPosition(); } scrollingTabContainerView.setTabSelected(i); if (this.mSelectedTab != null) { this.mSelectedTab.getCallback().onTabUnselected(this.mSelectedTab, trans); } this.mSelectedTab = (TabImpl) tab; if (this.mSelectedTab != null) { this.mSelectedTab.getCallback().onTabSelected(this.mSelectedTab, trans); } } else if (this.mSelectedTab != null) { this.mSelectedTab.getCallback().onTabReselected(this.mSelectedTab, trans); this.mTabScrollView.animateToTab(tab.getPosition()); } if (trans != null && !trans.isEmpty()) { trans.commit(); } }
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { return ScrollingTabContainerView.this.createTabView((Tab) getItem(position), true); } ((TabView) convertView).bindTab((Tab) getItem(position)); return convertView; }
public TabView(Context context, Tab tab, boolean forList) { super(context, null, R.attr.actionBarTabStyle); this.mTab = tab; TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, null, this.BG_ATTRS, R.attr.actionBarTabStyle, 0); if (a.hasValue(0)) { setBackgroundDrawable(a.getDrawable(0)); } a.recycle(); if (forList) { setGravity(8388627); } update(); }
private TabView createTabView(Tab tab, boolean forAdapter) { TabView tabView = new TabView(getContext(), tab, forAdapter); if (forAdapter) { tabView.setBackgroundDrawable(null); tabView.setLayoutParams(new AbsListView.LayoutParams(-1, this.mContentHeight)); } else { tabView.setFocusable(true); if (this.mTabClickListener == null) { this.mTabClickListener = new TabClickListener(); } tabView.setOnClickListener(this.mTabClickListener); } return tabView; }
public void addTab(Tab tab, boolean setSelected) { TabView tabView = createTabView(tab, false); this.mTabLayout.addView(tabView, new LayoutParams(0, -1, 1.0f)); if (this.mTabSpinner != null) { ((TabAdapter) this.mTabSpinner.getAdapter()).notifyDataSetChanged(); } if (setSelected) { tabView.setSelected(true); } if (this.mAllowCollapse) { requestLayout(); } }
public void addTab(Tab tab, int position, boolean setSelected) { TabView tabView = createTabView(tab, false); this.mTabLayout.addView(tabView, position, new LayoutParams(0, -1, 1.0f)); if (this.mTabSpinner != null) { ((TabAdapter) this.mTabSpinner.getAdapter()).notifyDataSetChanged(); } if (setSelected) { tabView.setSelected(true); } if (this.mAllowCollapse) { requestLayout(); } }
private void setupTabs() { int[] icons = new int[] { R.drawable.ic_tab_contacts, R.drawable.ic_tab_groups, R.drawable.ic_tab_recent }; for (int i = 0; i < icons.length; i++) { ActionBar.Tab tab = getSupportActionBar().newTab(); tab.setIcon(icons[i]); tab.setTabListener(new ViewPagerTabListener(i)); getSupportActionBar().addTab(tab); } }
public final View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { if (paramView == null) { return ScrollingTabContainerView.access$300$c6ad75e(ScrollingTabContainerView.this, (ActionBar.Tab)getItem(paramInt)); } ScrollingTabContainerView.TabView localTabView = (ScrollingTabContainerView.TabView)paramView; localTabView.mTab = ((ActionBar.Tab)getItem(paramInt)); localTabView.update(); return paramView; }
public TabView(Context paramContext, ActionBar.Tab paramTab, boolean paramBoolean) { super(null, R.attr.actionBarTabStyle); this.mTab = paramTab; TintTypedArray localTintTypedArray = TintTypedArray.obtainStyledAttributes$1a6c1917(paramContext, null, this.BG_ATTRS, R.attr.actionBarTabStyle); if (localTintTypedArray.hasValue(0)) { setBackgroundDrawable(localTintTypedArray.getDrawable(0)); } localTintTypedArray.mWrapped.recycle(); setGravity(8388627); update(); }
public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo paramAccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(paramAccessibilityNodeInfo); if (Build.VERSION.SDK_INT >= 14) { paramAccessibilityNodeInfo.setClassName(ActionBar.Tab.class.getName()); } }
public void onTabSelected(Tab tab, FragmentTransaction ft) { // Check if the fragment is already initialized if (mFragment == null) { // If not, instantiate and add it to the activity mFragment = Fragment.instantiate(mActivity, mClass.getName(), bundle); ft.add(R.id.content_frame, mFragment, mTag); } else { // If it exists, simply attach it in order to show it ft.attach(mFragment); } }
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); }
public void onTabSelected(Tab tab, FragmentTransaction ft) { FragmentTransaction sft = mActivity.getSupportFragmentManager() .beginTransaction(); // Check if the fragment is already initialized if (mFragment == null) { // If not, instantiate and add it to the activity mFragment = Fragment.instantiate(mActivity, mClass.getName()); sft.add(mfragmentContainerId, mFragment, mTag); } else { // If it exists, simply attach it in order to show it sft.attach(mFragment); } sft.commit(); }
public void onTabUnselected(Tab tab, FragmentTransaction ft) { FragmentTransaction sft = mActivity.getSupportFragmentManager() .beginTransaction(); if (mFragment != null) { // Detach the fragment, because another one is being attached sft.detach(mFragment); } sft.commit(); }
@Override public void onTabSelected(Tab tab, FragmentTransaction arg1) { viewPager.setCurrentItem(tab.getPosition()); Fragment curFrag = getSupportFragmentManager().findFragmentByTag( "android:switcher:" + R.id.mainContainer + ":" + viewPager.getCurrentItem()); if (curFrag != null && curFrag.isResumed()) ((OnDisplayFragment) curFrag).onDisplay(); if (tab.getPosition() == 0) { viewPager.setSwipingOnlyFromBorder(true); } else { viewPager.setSwipingOnlyFromBorder(false); } }
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) { TabInfo info = new TabInfo(clss, args); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBar.addTab(tab); notifyDataSetChanged(); }
@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); supportInvalidateOptionsMenu(); // update action bar options // refresh all that matter switch (Tabs.values()[tab.getPosition()]) { case MESSAGE: MessagesFragment mf = (MessagesFragment) findFragmentByPosition(Tabs.MESSAGE .ordinal()); if (mf != null) { mf.updateKeypad(); mf.updateValues(null); } break; case SLINGKEYS: SlingerFragment sf = (SlingerFragment) findFragmentByPosition(Tabs.SLINGKEYS .ordinal()); if (sf != null) { sf.updateKeypad(); sf.updateValues(null); } break; case INTRO: IntroductionFragment sif = (IntroductionFragment) findFragmentByPosition(Tabs.INTRO .ordinal()); if (sif != null) { sif.updateKeypad(); sif.updateValues(null); } break; default: break; } } } }
@Override public void onTabReselected(Tab tab, FragmentTransaction ft) { supportInvalidateOptionsMenu(); // update action bar options // refresh all that matter switch (Tabs.values()[tab.getPosition()]) { case MESSAGE: MessagesFragment mf = (MessagesFragment) findFragmentByPosition(Tabs.MESSAGE .ordinal()); if (mf != null) { mf.updateKeypad(); mf.updateValues(null); } break; case SLINGKEYS: SlingerFragment sf = (SlingerFragment) findFragmentByPosition(Tabs.SLINGKEYS .ordinal()); if (sf != null) { sf.updateKeypad(); sf.updateValues(null); } break; case INTRO: IntroductionFragment sif = (IntroductionFragment) findFragmentByPosition(Tabs.INTRO .ordinal()); if (sif != null) { sif.updateKeypad(); sif.updateValues(null); } break; default: break; } }
public void onTabSelected(Tab tab, FragmentTransaction sft) { // Check if the fragment is already initialized if (mFragment == null) { // If not, instantiate and add it to the activity mFragment = Fragment.instantiate(mActivity, mClass.getName(), mfragmentArgs); sft.add(mfragmentContainerId, mFragment, mTag); } else { // If it exists, simply attach it in order to show it sft.attach(mFragment); } }
@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.ll_contacts_fragment_container, contactsFragment, TAG_CONTACTS); ft.commit(); }
@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.ll_contacts_fragment_container, groupsFragment, TAG_GROUPS); ft.commit(); }
@Override public void onTabSelected(Tab tab, FragmentTransaction ft) { if (CommonMethod.isMeasure) return; // Check if the fragment is already initialized if (mFragment == null) { // If not, instantiate and add it to the activity mFragment = Fragment.instantiate(mActivity, mClass.getName()); ft.replace(android.R.id.content, mFragment, mTag); //http://code.google.com/p/android/issues/detail?id=58602#c30 } else { // If it exists, simply attach it in order to show it ft.attach(mFragment); } }
@Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { if (CommonMethod.isMeasure) return; if (mFragment != null) { // Detach the fragment, because another one is being attached ft.detach(mFragment); } }