void updateText(int currentItem, PagerAdapter adapter) {
    final int itemCount = adapter != null ? adapter.getCount() : 0;
    mUpdatingText = true;

    CharSequence text = null;
    if (currentItem >= 1 && adapter != null) {
      text = adapter.getPageTitle(currentItem - 1);
    }
    mPrevText.setText(text);

    mCurrText.setText(
        adapter != null && currentItem < itemCount ? adapter.getPageTitle(currentItem) : null);

    text = null;
    if (currentItem + 1 < itemCount && adapter != null) {
      text = adapter.getPageTitle(currentItem + 1);
    }
    mNextText.setText(text);

    // Measure everything
    final int width = getWidth() - getPaddingLeft() - getPaddingRight();
    final int childHeight = getHeight() - getPaddingTop() - getPaddingBottom();
    final int childWidthSpec =
        MeasureSpec.makeMeasureSpec((int) (width * 0.8f), MeasureSpec.AT_MOST);
    final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST);
    mPrevText.measure(childWidthSpec, childHeightSpec);
    mCurrText.measure(childWidthSpec, childHeightSpec);
    mNextText.measure(childWidthSpec, childHeightSpec);

    mLastKnownCurrentPage = currentItem;

    if (!mUpdatingPositions) {
      updateTextPositions(currentItem, mLastKnownPositionOffset, false);
    }

    mUpdatingText = false;
  }
Set the {@link Gravity} used to position text within the title strip.
Only the vertical gravity component is used.

@param gravity {@link Gravity} constant for positioning title text
sample/src/main/java/android/support/v4/view/PagerTitleStripV22.java