Ejemplo n.º 1
0
    public void setYear(int year) {
      if (mCurYear != year) {
        int old = mCurYear;
        mCurYear = year;

        CircleCheckedTextView child =
            (CircleCheckedTextView)
                YearPicker.this.getChildAt(
                    positionOfYear(old) - YearPicker.this.getFirstVisiblePosition());
        if (child != null) child.setChecked(false);

        child =
            (CircleCheckedTextView)
                YearPicker.this.getChildAt(
                    positionOfYear(mCurYear) - YearPicker.this.getFirstVisiblePosition());
        if (child != null) child.setChecked(true);

        if (mOnYearChangedListener != null) mOnYearChangedListener.onYearChanged(old, mCurYear);
      }
    }
Ejemplo n.º 2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      CircleCheckedTextView v = (CircleCheckedTextView) convertView;
      if (v == null) {
        v = new CircleCheckedTextView(getContext());
        v.setGravity(Gravity.CENTER);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
          v.setTextAlignment(TEXT_ALIGNMENT_CENTER);
        v.setMinHeight(mItemRealHeight);
        v.setMaxHeight(mItemRealHeight);
        v.setAnimDuration(mAnimDuration);
        v.setInterpolator(mInInterpolator, mOutInterpolator);
        v.setBackgroundColor(mSelectionColor);
        v.setTypeface(mTypeface);
        v.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
        v.setTextColor(new ColorStateList(STATES, mTextColors));
        v.setOnClickListener(this);
      }

      int year = (Integer) getItem(position);
      v.setTag(year);
      v.setText(String.format(YEAR_FORMAT, year));
      v.setCheckedImmediately(year == mCurYear);
      return v;
    }