Java Code Examples for com.google.android.material.tabs.TabLayout#getTabCount()

The following examples show how to use com.google.android.material.tabs.TabLayout#getTabCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabsMainDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void updateBadgeGravity(@BadgeGravity int badgeGravity) {
  for (TabLayout tabLayout : tabLayouts) {
    // Update the badge gravity on all the tabs.
    for (int index = 0; index < tabLayout.getTabCount(); index++) {
      BadgeDrawable badgeDrawable = tabLayout.getTabAt(index).getBadge();
      if (badgeDrawable != null) {
        badgeDrawable.setBadgeGravity(badgeGravity);
      }
    }
  }
}
 
Example 2
Source File: TabsControllableDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void setTabLayoutIcons(TabLayout tabLayout, @DrawableRes int iconResId) {
  for (int i = 0; i < tabLayout.getTabCount(); i++) {
    if (showIcons) {
      tabLayout.getTabAt(i).setIcon(iconResId);
    } else {
      tabLayout.getTabAt(i).setIcon(null);
    }
  }
}
 
Example 3
Source File: StickerSelectActivity.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.scribble_select_sticker_activity);

  ViewPager viewPager = findViewById(R.id.camera_sticker_pager);
  viewPager.setAdapter(new StickerPagerAdapter(getSupportFragmentManager(), this));

  TabLayout tabLayout = findViewById(R.id.camera_sticker_tabs);
  tabLayout.setupWithViewPager(viewPager);

  for (int i=0;i<tabLayout.getTabCount();i++) {
    tabLayout.getTabAt(i).setIcon(TAB_TITLES[i]);
  }
}
 
Example 4
Source File: TabLayoutMediator.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageSelected(final int position) {
    TabLayout tabLayout = mTabLayoutRef.get();
    if (tabLayout != null
            && tabLayout.getSelectedTabPosition() != position
            && position < tabLayout.getTabCount()) {
        // Select the tab, only updating the indicator if we're not being dragged/settled
        // (since onPageScrolled will handle that).
        boolean updateIndicator = mScrollState == SCROLL_STATE_IDLE
                || (mScrollState == SCROLL_STATE_SETTLING
                && mPreviousScrollState == SCROLL_STATE_IDLE);
        selectTab(tabLayout, tabLayout.getTabAt(position), updateIndicator);
    }
}
 
Example 5
Source File: TabsControllableDemoFragment.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
private void setTabLayoutText(TabLayout tabLayout, @StringRes int stringResId) {
  for (int i = 0; i < tabLayout.getTabCount(); i++) {
    // Convert tab index (zero-based) to readable tab label starting at 1.
    tabLayout.getTabAt(i).setText(getResources().getString(stringResId, i + 1));
  }
}
 
Example 6
Source File: TabsControllableDemoFragment.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
private void setLabelVisibility(TabLayout tabLayout, @LabelVisibility int mode) {
   for (int i = 0; i < tabLayout.getTabCount(); i++) {
    tabLayout.getTabAt(i).setTabLabelVisibility(mode);
  }
}