Пример #1
0
 @Override
 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
   if (mItemCount == 0) {
     return;
   }
   int n = position % mItemCount;
   setItemAsSelected(n - 1);
 }
Пример #2
0
  /** redraw the indicators. */
  public void redraw() {
    mItemCount = getShouldDrawCount();
    mPreviousSelectedIndicator = null;
    for (View i : mIndicators) {
      removeView(i);
    }

    for (int i = 0; i < mItemCount; i++) {
      ImageView indicator = new ImageView(mContext);
      indicator.setImageDrawable(mUnselectedDrawable);
      indicator.setPadding(
          (int) mUnSelectedPadding_Left,
          (int) mUnSelectedPadding_Top,
          (int) mUnSelectedPadding_Right,
          (int) mUnSelectedPadding_Bottom);
      addView(indicator);
      mIndicators.add(indicator);
    }
    setItemAsSelected(mPreviousSelectedPosition);
  }