private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
      View tabView = null;
      TextView tabTitleView = null;

      if (mTabViewLayoutId != 0) {
        // If there is a custom tab view layout id set, try and inflate it
        tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
        tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
      }

      if (tabView == null) {
        tabView = createDefaultTabView(getContext());
      }

      if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        tabTitleView = (TextView) tabView;
      }

      if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
      }

      tabTitleView.setText(adapter.getPageTitle(i));
      tabView.setOnClickListener(tabClickListener);
      String desc = mContentDescriptions.get(i, null);
      if (desc != null) {
        tabView.setContentDescription(desc);
      }

      mTabStrip.addView(tabView);
      if (i == mViewPager.getCurrentItem()) {
        tabView.setSelected(true);
        TextView t = (TextView) mTabStrip.getChildAt(i);
        final TabsPagerAdapter cAdapter = (TabsPagerAdapter) mViewPager.getAdapter();
        t.setText(cAdapter.getActivePageTitle(i));
      }
    }
  }
    @Override
    public void onPageSelected(int position) {
      if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
        mTabStrip.onViewPagerPageChanged(position, 0f);
        scrollToTab(position, 0);
      }
      final TabsPagerAdapter adapter = (TabsPagerAdapter) mViewPager.getAdapter();

      for (int i = 0; i < mTabStrip.getChildCount(); i++) {
        mTabStrip.getChildAt(i).setSelected(position == i);
        TextView t = (TextView) mTabStrip.getChildAt(i);
        if (i == position) {
          t.setText(adapter.getActivePageTitle(i));
        } else {
          t.setText(adapter.getPageTitle(i));
        }
      }
      if (mViewPagerPageChangeListener != null) {
        mViewPagerPageChangeListener.onPageSelected(position);
      }
    }