| AndBase开发框架 1.6

- 首页
- 相关页面
- 命名空间
- 类
- 文件

- 类列表
- 类索引
- 类继承关系
- 类成员

全部 类 命名空间 文件 函数 变量 枚举值 页
类 | Public 成员函数 | Protected 成员函数 | 包函数 | 包属性 | Private 成员函数 | Private 属性 | 静态 Private 属性 | 所有成员列表
com.ab.view.wheel.AbWheelView类 参考
类 com.ab.view.wheel.AbWheelView 继承关系图:

## 类
interface | AbOnWheelChangedListener
interface | AbOnWheelScrollListener

## Public 成员函数
| AbWheelView (Context context, AttributeSet attrs, int defStyle)
| AbWheelView (Context context, AttributeSet attrs)
| AbWheelView (Context context)
AbWheelAdapter | getAdapter ()
void | setAdapter (AbWheelAdapter adapter)
void | setInterpolator (Interpolator interpolator)
int | getVisibleItems ()
void | setVisibleItems (int count)
String | getLabel ()
void | setLabel (String newLabel)
void | addChangingListener (AbOnWheelChangedListener listener)
void | removeChangingListener (AbOnWheelChangedListener listener)
void | addScrollingListener (AbOnWheelScrollListener listener)
void | removeScrollingListener (AbOnWheelScrollListener listener)
int | getCurrentItem ()
void | setCurrentItem (int index, boolean animated)
void | setCurrentItem (int index)
boolean | isCyclic ()
void | setCyclic (boolean isCyclic)
boolean | onTouchEvent (MotionEvent event)
void | scroll (int itemsToScroll, int time)
void | setValueTextSize (int textSize)
int[] | getCenterSelectGradientColors ()
void | setCenterSelectGradientColors (int[] centerSelectGradientColors)
int | getCenterSelectStrokeWidth ()
void | setCenterSelectStrokeWidth (int centerSelectStrokeWidth)
int | getCenterSelectStrokeColor ()
void | setCenterSelectStrokeColor (int centerSelectStrokeColor)
void | setCenterSelectDrawable (Drawable centerSelectDrawable)
void | setValueTextColor (int valueTextColor)
void | setLabelTextColor (int labelTextColor)
void | setLabelTextSize (int labelTextSize)
void | setAdditionalItemHeight (int additionalItemHeight)

## Protected 成员函数
void | notifyChangingListeners (int oldValue, int newValue)
void | notifyScrollingListenersAboutStart ()
void | notifyScrollingListenersAboutEnd ()
void | onMeasure (int widthMeasureSpec, int heightMeasureSpec)
void | onDraw (Canvas canvas)

## 包函数
void | finishScrolling ()

## 包属性
boolean | isCyclic = false

## Private 成员函数
void | initData (Context context)
void | invalidateLayouts ()
void | initResourcesIfNecessary ()
int | getDesiredHeight (Layout layout)
String | getTextItem (int index)
String | buildText (boolean useCurrentValue)
int | getMaxTextLength ()
int | getItemHeight ()
int | calculateLayoutWidth (int widthSize, int mode)
void | createLayouts (int widthItems, int widthLabel)
void | drawShadows (Canvas canvas)
void | drawValue (Canvas canvas)
void | drawItems (Canvas canvas)
void | drawCenterRect (Canvas canvas)
void | doScroll (int delta)
void | setNextMessage (int message)
void | clearMessages ()
void | justify ()
void | startScrolling ()

## Private 属性
Context | mContext = null
AbWheelAdapter | adapter = null
int | currentItem = 0
int | itemsWidth = 0
int | labelWidth = 0
int | visibleItems = DEF_VISIBLE_ITEMS
int | itemHeight = 0
TextPaint | itemsPaint
TextPaint | valuePaint
TextPaint | labelPaint
StaticLayout | itemsLayout
StaticLayout | labelLayout
StaticLayout | valueLayout
String | label
boolean | isScrollingPerformed
int | scrollingOffset
GestureDetector | gestureDetector
Scroller | scroller
int | lastScrollY
List< AbOnWheelChangedListener > | changingListeners = new LinkedList<AbOnWheelChangedListener>()
List< AbOnWheelScrollListener > | scrollingListeners = new LinkedList<AbOnWheelScrollListener>()
Drawable | centerSelectDrawable
int[] | centerSelectGradientColors = new int[] {0x70222222,0x70222222, 0x70EEEEEE}
int | centerSelectStrokeWidth = 1
int | centerSelectStrokeColor = 0x70333333
GradientDrawable | topShadow
GradientDrawable | bottomShadow
int | valueTextColor = 0xF0000000
int | labelTextColor = 0xF0000000
int[] | bottomGradientColors = new int[] { 0x333, 0xDDD, 0x333 }
int[] | topGradientColors = new int[] { 0xAAA, 0xFFF, 0xAAA }
int | topStrokeWidth = 1
int | topStrokeColor = 0xFF333333
int | valueTextSize = 35
int | labelTextSize = 35
int | itemOffset = valueTextSize / 5
int | additionalItemHeight = 30
int | screenWidth = 0
int | screenHeight = 0
SimpleOnGestureListener | gestureListener
final int | MESSAGE_SCROLL = 0
final int | MESSAGE_JUSTIFY = 1
Handler | animationHandler

## 静态 Private 属性
static final int | SCROLLING_DURATION = 400
static final int | MIN_DELTA_FOR_SCROLLING = 1
static final int | ITEMS_TEXT_COLOR = 0xFF000000
static int[] | SHADOWS_COLORS = new int[] { 0xFF111111, 0x00AAAAAA, 0x00AAAAAA }
static final int | LABEL_OFFSET = 8
static final int | PADDING = 5
static final int | DEF_VISIBLE_ITEMS = 5

## 详细描述

© 2012 amsoft.cn 名称：AbWheelView.java 描述：轮子View

作者
  还如一梦中

版本
  v1.0

日期
  ：2013-05-17 下午6:46:29

## 构造及析构函数说明

com.ab.view.wheel.AbWheelView.AbWheelView | ( | Context | context,
|  | AttributeSet | attrs,
|  | int | defStyle
| ) |  |
| inline

Constructor.

参数

  context | the context
  attrs | the attrs
  defStyle | the def style

com.ab.view.wheel.AbWheelView.AbWheelView | ( | Context | context,
|  | AttributeSet | attrs
| ) |  |
| inline

Constructor.

参数

  context | the context
  attrs | the attrs

com.ab.view.wheel.AbWheelView.AbWheelView | ( | Context | context | ) |
| inline

Constructor.

参数

  context | the context

## 成员函数说明

void com.ab.view.wheel.AbWheelView.addChangingListener | ( | AbOnWheelChangedListener | listener | ) |
| inline

Adds wheel changing listener.

参数

  listener | the listener

void com.ab.view.wheel.AbWheelView.addScrollingListener | ( | AbOnWheelScrollListener | listener | ) |
| inline

Adds wheel scrolling listener.

参数

  listener | the listener

String com.ab.view.wheel.AbWheelView.buildText | ( | boolean | useCurrentValue | ) |
| inline private

Builds text depending on current value.

参数

  useCurrentValue | the use current value

返回
  the text

int com.ab.view.wheel.AbWheelView.calculateLayoutWidth | ( | int | widthSize,
|  | int | mode
| ) |  |
| inline private

Calculates control width and creates text layouts.

参数

  widthSize | the input layout width
  mode | the layout mode

返回
  the calculated control width

void com.ab.view.wheel.AbWheelView.clearMessages | ( |  | ) |
| inline private

Clears messages from queue.

void com.ab.view.wheel.AbWheelView.createLayouts | ( | int | widthItems,
|  | int | widthLabel
| ) |  |
| inline private

Creates layouts.

参数

  widthItems | width of items layout
  widthLabel | width of label layout

void com.ab.view.wheel.AbWheelView.doScroll | ( | int | delta | ) |
| inline private

Scrolls the wheel.

参数

  delta | the scrolling value

void com.ab.view.wheel.AbWheelView.drawCenterRect | ( | Canvas | canvas | ) |
| inline private

Draws rect for current value.

参数

  canvas | the canvas for drawing

void com.ab.view.wheel.AbWheelView.drawItems | ( | Canvas | canvas | ) |
| inline private

Draws items.

参数

  canvas | the canvas for drawing

void com.ab.view.wheel.AbWheelView.drawShadows | ( | Canvas | canvas | ) |
| inline private

Draws shadows on top and bottom of control.

参数

  canvas | the canvas for drawing

void com.ab.view.wheel.AbWheelView.drawValue | ( | Canvas | canvas | ) |
| inline private

Draws value and label layout.

参数

  canvas | the canvas for drawing

void com.ab.view.wheel.AbWheelView.finishScrolling | ( |  | ) |
| inline package

Finishes scrolling.

AbWheelAdapter com.ab.view.wheel.AbWheelView.getAdapter | ( |  | ) |
| inline

Gets wheel adapter.

返回
  the adapter

int [] com.ab.view.wheel.AbWheelView.getCenterSelectGradientColors | ( |  | ) |
| inline

Gets the center select gradient colors.

返回
  the center select gradient colors

int com.ab.view.wheel.AbWheelView.getCenterSelectStrokeColor | ( |  | ) |
| inline

Gets the center select stroke color.

返回
  the center select stroke color

int com.ab.view.wheel.AbWheelView.getCenterSelectStrokeWidth | ( |  | ) |
| inline

Gets the center select stroke width.

返回
  the center select stroke width

int com.ab.view.wheel.AbWheelView.getCurrentItem | ( |  | ) |
| inline

Gets current value.

返回
  the current value

int com.ab.view.wheel.AbWheelView.getDesiredHeight | ( | Layout | layout | ) |
| inline private

Calculates desired height for layout.

参数

  layout | the source layout

返回
  the desired layout height

int com.ab.view.wheel.AbWheelView.getItemHeight | ( |  | ) |
| inline private

Returns height of wheel item.

返回
  the item height

String com.ab.view.wheel.AbWheelView.getLabel | ( |  | ) |
| inline

Gets label.

返回
  the label

int com.ab.view.wheel.AbWheelView.getMaxTextLength | ( |  | ) |
| inline private

Returns the max item length that can be present.

返回
  the max length

String com.ab.view.wheel.AbWheelView.getTextItem | ( | int | index | ) |
| inline private

Returns text item by index.

参数

  index | the item index

返回
  the item or null

int com.ab.view.wheel.AbWheelView.getVisibleItems | ( |  | ) |
| inline

Gets count of visible items.

返回
  the count of visible items

void com.ab.view.wheel.AbWheelView.initData | ( | Context | context | ) |
| inline private

Initializes class data.

参数

  context | the context

void com.ab.view.wheel.AbWheelView.initResourcesIfNecessary | ( |  | ) |
| inline private

Initializes resources.

void com.ab.view.wheel.AbWheelView.invalidateLayouts | ( |  | ) |
| inline private

Invalidates layouts.

boolean com.ab.view.wheel.AbWheelView.isCyclic | ( |  | ) |
| inline

Tests if wheel is cyclic. That means before the 1st item there is shown the last one

返回
  true if wheel is cyclic

void com.ab.view.wheel.AbWheelView.justify | ( |  | ) |
| inline private

Justifies wheel.

void com.ab.view.wheel.AbWheelView.notifyChangingListeners | ( | int | oldValue,
|  | int | newValue
| ) |  |
| inline protected

Notifies changing listeners.

参数

  oldValue | the old wheel value
  newValue | the new wheel value

void com.ab.view.wheel.AbWheelView.notifyScrollingListenersAboutEnd | ( |  | ) |
| inline protected

Notifies listeners about ending scrolling.

void com.ab.view.wheel.AbWheelView.notifyScrollingListenersAboutStart | ( |  | ) |
| inline protected

Notifies listeners about starting scrolling.

void com.ab.view.wheel.AbWheelView.onDraw | ( | Canvas | canvas | ) |
| inline protected

描述：TODO.

版本
  v1.0

参数

  canvas | the canvas

参见
  android.view.View::onDraw(android.graphics.Canvas)

作者
  : amsoft.cn

日期
  ：2013-6-17 上午9:04:47

void com.ab.view.wheel.AbWheelView.onMeasure | ( | int | widthMeasureSpec,
|  | int | heightMeasureSpec
| ) |  |
| inline protected

描述：TODO.

版本
  v1.0

参数

  widthMeasureSpec | the width measure spec
  heightMeasureSpec | the height measure spec

参见
  android.view.View::onMeasure(int, int)

作者
  : amsoft.cn

日期
  ：2013-6-17 上午9:04:47

boolean com.ab.view.wheel.AbWheelView.onTouchEvent | ( | MotionEvent | event | ) |
| inline

描述：TODO.

版本
  v1.0

参数

  event | the event

返回
  true, if successful

参见
  android.view.View::onTouchEvent(android.view.MotionEvent)

作者
  : amsoft.cn

日期
  ：2013-6-17 上午9:04:47

void com.ab.view.wheel.AbWheelView.removeChangingListener | ( | AbOnWheelChangedListener | listener | ) |
| inline

Removes wheel changing listener.

参数

  listener | the listener

void com.ab.view.wheel.AbWheelView.removeScrollingListener | ( | AbOnWheelScrollListener | listener | ) |
| inline

Removes wheel scrolling listener.

参数

  listener | the listener

void com.ab.view.wheel.AbWheelView.scroll | ( | int | itemsToScroll,
|  | int | time
| ) |  |
| inline

Scroll the wheel.

参数

  itemsToScroll | the items to scroll
  time | scrolling duration

void com.ab.view.wheel.AbWheelView.setAdapter | ( | AbWheelAdapter | adapter | ) |
| inline

Sets wheel adapter.

参数

  adapter | the new wheel adapter

void com.ab.view.wheel.AbWheelView.setAdditionalItemHeight | ( | int | additionalItemHeight | ) |
| inline

Sets the additional item height.

参数

  additionalItemHeight | the new additional item height

void com.ab.view.wheel.AbWheelView.setCenterSelectDrawable | ( | Drawable | centerSelectDrawable | ) |
| inline

描述：设置中间的选中层图片.

参数

  centerSelectDrawable | the new center select drawable

void com.ab.view.wheel.AbWheelView.setCenterSelectGradientColors | ( | int[] | centerSelectGradientColors | ) |
| inline

Sets the center select gradient colors.

参数

  centerSelectGradientColors | the new center select gradient colors

void com.ab.view.wheel.AbWheelView.setCenterSelectStrokeColor | ( | int | centerSelectStrokeColor | ) |
| inline

Sets the center select stroke color.

参数

  centerSelectStrokeColor | the new center select stroke color

void com.ab.view.wheel.AbWheelView.setCenterSelectStrokeWidth | ( | int | centerSelectStrokeWidth | ) |
| inline

Sets the center select stroke width.

参数

  centerSelectStrokeWidth | the new center select stroke width

void com.ab.view.wheel.AbWheelView.setCurrentItem | ( | int | index,
|  | boolean | animated
| ) |  |
| inline

Sets the current item. Does nothing when index is wrong.

参数

  index | the item index
  animated | the animation flag

void com.ab.view.wheel.AbWheelView.setCurrentItem | ( | int | index | ) |
| inline

Sets the current item w/o animation. Does nothing when index is wrong.

参数

  index | the item index

void com.ab.view.wheel.AbWheelView.setCyclic | ( | boolean | isCyclic | ) |
| inline

Set wheel cyclic flag.

参数

  isCyclic | the flag to set

void com.ab.view.wheel.AbWheelView.setInterpolator | ( | Interpolator | interpolator | ) |
| inline

Set the the specified scrolling interpolator.

参数

  interpolator | the interpolator

void com.ab.view.wheel.AbWheelView.setLabel | ( | String | newLabel | ) |
| inline

Sets label.

参数

  newLabel | the label to set

void com.ab.view.wheel.AbWheelView.setLabelTextColor | ( | int | labelTextColor | ) |
| inline

Sets the label text color.

参数

  labelTextColor | the new label text color

void com.ab.view.wheel.AbWheelView.setLabelTextSize | ( | int | labelTextSize | ) |
| inline

Sets the label text size.

参数

  labelTextSize | the new label text size

void com.ab.view.wheel.AbWheelView.setNextMessage | ( | int | message | ) |
| inline private

Set next message to queue. Clears queue before.

参数

  message | the message to set

void com.ab.view.wheel.AbWheelView.setValueTextColor | ( | int | valueTextColor | ) |
| inline

Sets the value text color.

参数

  valueTextColor | the new value text color

void com.ab.view.wheel.AbWheelView.setValueTextSize | ( | int | textSize | ) |
| inline

Sets the value text size.

参数

  textSize | the new value text size

void com.ab.view.wheel.AbWheelView.setVisibleItems | ( | int | count | ) |
| inline

Sets count of visible items.

参数

  count | the new count

void com.ab.view.wheel.AbWheelView.startScrolling | ( |  | ) |
| inline private

Starts scrolling.

## 类成员变量说明

AbWheelAdapter com.ab.view.wheel.AbWheelView.adapter = null
| private

The adapter.

int com.ab.view.wheel.AbWheelView.additionalItemHeight = 30
| private

中间覆盖条高度.

Handler com.ab.view.wheel.AbWheelView.animationHandler
| private

初始值:
= new Handler() {
public void handleMessage(Message msg) {
scroller.computeScrollOffset();
int currY = scroller.getCurrY();
int delta = lastScrollY - currY;
lastScrollY = currY;
if (delta != 0) {
doScroll(delta);
}
if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
currY = scroller.getFinalY();
scroller.forceFinished(true);
}
if (!scroller.isFinished()) {
animationHandler.sendEmptyMessage(msg.what);
} else if (msg.what == MESSAGE_SCROLL) {
justify();
} else {
finishScrolling();
}
}
}

The animation handler.

int [] com.ab.view.wheel.AbWheelView.bottomGradientColors = new int[] { 0x333, 0xDDD, 0x333 }
| private

The bottom gradient colors.

GradientDrawable com.ab.view.wheel.AbWheelView.bottomShadow
| private

The bottom shadow.

Drawable com.ab.view.wheel.AbWheelView.centerSelectDrawable
| private

中间覆盖条的背景图.

int [] com.ab.view.wheel.AbWheelView.centerSelectGradientColors = new int[] {0x70222222,0x70222222, 0x70EEEEEE}
| private

中间覆盖条的颜色，如果没有设置centerDrawable时才生效.

int com.ab.view.wheel.AbWheelView.centerSelectStrokeColor = 0x70333333
| private

The center select stroke color.

int com.ab.view.wheel.AbWheelView.centerSelectStrokeWidth = 1
| private

The center select stroke width.

List<AbOnWheelChangedListener> com.ab.view.wheel.AbWheelView.changingListeners = new LinkedList<AbOnWheelChangedListener>()
| private

The changing listeners.

int com.ab.view.wheel.AbWheelView.currentItem = 0
| private

The current item.

final int com.ab.view.wheel.AbWheelView.DEF_VISIBLE_ITEMS = 5
| static private

Default count of visible items.

GestureDetector com.ab.view.wheel.AbWheelView.gestureDetector
| private

The gesture detector.

SimpleOnGestureListener com.ab.view.wheel.AbWheelView.gestureListener
| private

初始值:
= new SimpleOnGestureListener() {
public boolean onDown(MotionEvent e) {
if (isScrollingPerformed) {
scroller.forceFinished(true);
clearMessages();
return true;
}
return false;
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
startScrolling();
doScroll((int) -distanceY);
return true;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
lastScrollY = currentItem * getItemHeight() + scrollingOffset;
int maxY = isCyclic ? 0x7FFFFFFF : adapter.getItemsCount() * getItemHeight();
int minY = isCyclic ? -maxY : 0;
scroller.fling(0, lastScrollY, 0, (int) -velocityY / 2, 0, 0, minY, maxY);
setNextMessage(MESSAGE_SCROLL);
return true;
}
}

The gesture listener.

boolean com.ab.view.wheel.AbWheelView.isCyclic = false
| package

The is cyclic.

boolean com.ab.view.wheel.AbWheelView.isScrollingPerformed
| private

The is scrolling performed.

int com.ab.view.wheel.AbWheelView.itemHeight = 0
| private

The item height.

int com.ab.view.wheel.AbWheelView.itemOffset = valueTextSize / 5
| private

Top and bottom items offset.

final int com.ab.view.wheel.AbWheelView.ITEMS_TEXT_COLOR = 0xFF000000
| static private

Items text color.

StaticLayout com.ab.view.wheel.AbWheelView.itemsLayout
| private

The items layout.

TextPaint com.ab.view.wheel.AbWheelView.itemsPaint
| private

The items paint.

int com.ab.view.wheel.AbWheelView.itemsWidth = 0
| private

The items width.

String com.ab.view.wheel.AbWheelView.label
| private

The label.

final int com.ab.view.wheel.AbWheelView.LABEL_OFFSET = 8
| static private

Label offset.

StaticLayout com.ab.view.wheel.AbWheelView.labelLayout
| private

The label layout.

TextPaint com.ab.view.wheel.AbWheelView.labelPaint
| private

The label paint.

int com.ab.view.wheel.AbWheelView.labelTextColor = 0xF0000000
| private

Current label text color.

int com.ab.view.wheel.AbWheelView.labelTextSize = 35
| private

标签的文字大小.

int com.ab.view.wheel.AbWheelView.labelWidth = 0
| private

The label width.

int com.ab.view.wheel.AbWheelView.lastScrollY
| private

The last scroll y.

Context com.ab.view.wheel.AbWheelView.mContext = null
| private

The m context.

final int com.ab.view.wheel.AbWheelView.MESSAGE_JUSTIFY = 1
| private

The message justify.

final int com.ab.view.wheel.AbWheelView.MESSAGE_SCROLL = 0
| private

The message scroll.

final int com.ab.view.wheel.AbWheelView.MIN_DELTA_FOR_SCROLLING = 1
| static private

Minimum delta for scrolling.

final int com.ab.view.wheel.AbWheelView.PADDING = 5
| static private

Left and right padding value.

int com.ab.view.wheel.AbWheelView.screenHeight = 0
| private

屏幕高度.

int com.ab.view.wheel.AbWheelView.screenWidth = 0
| private

屏幕宽度.

Scroller com.ab.view.wheel.AbWheelView.scroller
| private

The scroller.

final int com.ab.view.wheel.AbWheelView.SCROLLING_DURATION = 400
| static private

Scrolling duration.

List<AbOnWheelScrollListener> com.ab.view.wheel.AbWheelView.scrollingListeners = new LinkedList<AbOnWheelScrollListener>()
| private

The scrolling listeners.

int com.ab.view.wheel.AbWheelView.scrollingOffset
| private

The scrolling offset.

int [] com.ab.view.wheel.AbWheelView.SHADOWS_COLORS = new int[] { 0xFF111111, 0x00AAAAAA, 0x00AAAAAA }
| static private

Top and bottom shadows colors.

int [] com.ab.view.wheel.AbWheelView.topGradientColors = new int[] { 0xAAA, 0xFFF, 0xAAA }
| private

The top gradient colors.

GradientDrawable com.ab.view.wheel.AbWheelView.topShadow
| private

Shadows drawables.

int com.ab.view.wheel.AbWheelView.topStrokeColor = 0xFF333333
| private

The top stroke color.

int com.ab.view.wheel.AbWheelView.topStrokeWidth = 1
| private

The top stroke width.

StaticLayout com.ab.view.wheel.AbWheelView.valueLayout
| private

The value layout.

TextPaint com.ab.view.wheel.AbWheelView.valuePaint
| private

The value paint.

int com.ab.view.wheel.AbWheelView.valueTextColor = 0xF0000000
| private

Current value.

int com.ab.view.wheel.AbWheelView.valueTextSize = 35
| private

值的文字大小.

int com.ab.view.wheel.AbWheelView.visibleItems = DEF_VISIBLE_ITEMS
| private

The visible items.

该类的文档由以下文件生成:

- src/com/ab/view/wheel/AbWheelView.java