public class Rating extends AbsSlider
This class provides a rating with rating items such as stars (or elements) to represent a rating level.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
Rating.RatingChangedListener |
Callback to process change events of a rating.
|
AbsSlider.FormatterComponent.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEventProgressBar.BarObserverACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLE| 构造器 | 说明 |
|---|---|
Rating(Context context) |
Default constructor used to create a
Rating instance by using the default
attribute set and style. |
Rating(Context context,
AttrSet attrSet) |
A constructor used to create a
Rating instance by using specified attribute
set and default style
after the XML file is parsed. |
Rating(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
Rating instance by using specified attribute
set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Element |
getFilledElement() |
Obtains the filled element from the rating item.
|
float |
getGrainSize() |
Obtains the step size (granularity) of a rating item.
|
Element |
getHalfFilledElement() |
Obtains the half-filled element from the rating item.
|
int |
getRatingItems() |
Obtains the number of current rating items.
|
float |
getScore() |
Obtains the current rating score.
|
Element |
getThumbElement() |
Obtains the current element thumb.
|
Element |
getUnfilledElement() |
Obtains the unfilled element from the rating item.
|
boolean |
isOperable() |
Checks whether rating is inoperable.
|
void |
setFilledElement(Element element) |
Sets the specified
Element object to a filled element for the rating item. |
void |
setGrainSize(float size) |
Sets the step size of a rating item.
|
void |
setHalfFilledElement(Element element) |
Sets the specified
Element object to a half-filled element for the rating item. |
void |
setIsOperable(boolean isOperable) |
Sets whether rating is inoperable.
|
void |
setRatingChangedListener(Rating.RatingChangedListener listener) |
Sets a change listener to process change events of a rating.
|
void |
setRatingItems(int numberItems) |
Sets the number of rating items indicated by asterisks or other symbols to represent the rating level.
|
void |
setScore(float score) |
Sets the rating score.
|
void |
setThumbElement(Element element) |
Sets an element thumb.
|
void |
setUnfilledElement(Element element) |
Sets the specified
Element object to an unfilled element for the rating item. |
getFormatter, setFormatteraddDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, dispatchRestoreState, dispatchSaveState, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findComponentById, findComponentHolderById, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectBoundaryWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, informConfigurationChanged, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onDrag, onRestoreState, onRtlChanged, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectBoundaryWidth, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddBarObserver, enableDividerLines, getBackgroundInstructElement, getDividerLineColor, getDividerLinesNumber, getDividerLineThickness, getInfiniteModeElement, getMax, getMaxHeight, getMaxWidth, getMin, getOrientation, getProgress, getProgressColor, getProgressColors, getProgressElement, getProgressHintText, getProgressHintTextAlignment, getProgressHintTextColor, getProgressHintTextSize, getProgressWidth, getStep, getViceProgressElement, getViceProgressValue, isDividerLinesEnabled, isIndeterminate, isInfiniteMode, removeBarObserver, setDividerLineColor, setDividerLinesNumber, setDividerLineThickness, setIndeterminate, setInfiniteModeElement, setMaxHeight, setMaxValue, setMaxWidth, setMinValue, setOrientation, setProgressBackgroundElement, setProgressColor, setProgressColors, setProgressElement, setProgressHintText, setProgressHintTextAlignment, setProgressHintTextColor, setProgressHintTextSize, setProgressValue, setProgressWidth, setStep, setViceProgress, setViceProgressElementpublic Rating(Context context)
Rating instance by using the default
attribute set and style.context - Indicates the application context.public Rating(Context context, AttrSet attrSet)
Rating instance by using specified attribute
set and default style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public Rating(Context context, AttrSet attrSet, String styleName)
Rating instance by using specified attribute
set and specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public float getGrainSize()
public void setGrainSize(float size)
size - Indicates the step size to set.IllegalArgumentException - Throws the exception if the size value less than or equals 0 or
more than number of rating items see Rating#getRatingItems()public void setScore(float score)
score - Indicates the score to set, which is a floating-point value.IllegalArgumentException - Throws the exception if the score value less than 0public float getScore()
public void setIsOperable(boolean isOperable)
isOperable - Specifies whether rating is inoperable.
Value true indicates that rating is inoperable, and false indicates the opposite.public boolean isOperable()
true if rating is inoperable; returns false otherwise.public void setRatingItems(int numberItems)
numberItems - Indicates the number of rating items.IllegalArgumentException - Throws the exception if the value less than 0 or
more than upper limit of rating items RATING_MAX_ITEMSpublic int getRatingItems()
Generally, a higher rating level is represented by a larger number of asterisks (or other symbols).
public void setRatingChangedListener(Rating.RatingChangedListener listener)
listener - Indicates the change listener passed by the application to process change events of a rating.public void setFilledElement(Element element)
Element object to a filled element for the rating item.element - Indicates the Element object to set.public Element getFilledElement()
Element object.public void setUnfilledElement(Element element)
Element object to an unfilled element for the rating item.element - Indicates the Element object to set.public Element getHalfFilledElement()
Element object.public void setHalfFilledElement(Element element)
Element object to a half-filled element for the rating item.element - Indicates the Element object to set.public Element getUnfilledElement()
Element object.public Element getThumbElement()
AbsSlidergetThumbElement 在类中 AbsSliderpublic void setThumbElement(Element element)
AbsSlidersetThumbElement 在类中 AbsSliderelement - Indicates the element thumb.