Added in API level 11

NumberPicker


open class NumberPicker : LinearLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.LinearLayout
   ↳ android.widget.NumberPicker

A widget that enables the user to select a number from a predefined range. There are two flavors of this widget and which one is presented to the user depends on the current theme.

  • If the current theme is derived from android.R.style#Theme the widget presents the current value as an editable input field with an increment button above and a decrement button below. Long pressing the buttons allows for a quick change of the current value. Tapping on the input field allows to type in a desired value.
  • If the current theme is derived from android.R.style#Theme_Holo or android.R.style#Theme_Holo_Light the widget presents the current value as an editable input field with a lesser value above and a greater value below. Tapping on the lesser or greater value selects it by animating the number axis up or down to make the chosen value current. Flinging up or down allows for multiple increments or decrements of the current value. Long pressing on the lesser and greater values also allows for a quick change of the current value. Tapping on the current value allows to type in a desired value.
  • If the current theme is derived from android.R.style#Theme_Material the widget presents the current value as a scrolling vertical selector with the selected value in the center and the previous and following numbers above and below, separated by a divider. The value is changed by flinging vertically. The thickness of the divider can be changed by using the android.R.attr#selectionDividerHeight attribute and the color of the divider can be changed by using the android.R.attr#colorControlNormal attribute.

For an example of using this widget, see android.widget.TimePicker.

Summary

Nested classes
abstract

Interface used to format current value into a string for presentation.

abstract

Interface to listen for the picker scroll state.

abstract

Interface to listen for changes of the current value.

Inherited XML attributes
Inherited constants
Public constructors
NumberPicker(context: Context!)

Create a new number picker.

NumberPicker(context: Context!, attrs: AttributeSet!)

Create a new number picker.

NumberPicker(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Create a new number picker

NumberPicker(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Create a new number picker

Public methods
open Unit

open Boolean

open Boolean

open Boolean

open AccessibilityNodeProvider!

open Array<String!>!

Gets the values to be displayed instead of string values.

open Int

Returns the max value of the picker.

open Int

Returns the min value of the picker.

open Int

Retrieve the height for the divider that separates the currently selected value from the others.

open Int

open Int

open Float

open Int

Returns the value of the picker.

open Boolean

Gets whether the selector wheel wraps when reaching the min/max value.

open Unit

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

open Boolean

open Boolean

open Boolean

open Boolean

open Unit
scrollBy(x: Int, y: Int)

open Unit
setDisplayedValues(displayedValues: Array<String!>!)

Sets the values to be displayed.

open Unit
setEnabled(enabled: Boolean)

open Unit

Set the formatter to be used for formatting the current value.

open Unit
setMaxValue(maxValue: Int)

Sets the max value of the picker.

open Unit
setMinValue(minValue: Int)

Sets the min value of the picker.

open Unit

Sets the speed at which the numbers be incremented and decremented when the up and down buttons are long pressed respectively.

open Unit

Set listener to be notified for scroll state changes.

open Unit

Sets the listener to be notified on change of the current value.

open Unit

Set the height for the divider that separates the currently selected value from the others.

open Unit
setTextColor(color: Int)

Sets the text color for all the states (normal, selected, focused) to be the given color.

open Unit

Sets the text size to the given value.

open Unit
setValue(value: Int)

Set the current value for the number picker.

open Unit
setWrapSelectorWheel(wrapSelectorWheel: Boolean)

Sets whether the selector wheel shown during flinging/scrolling should wrap around the NumberPicker.getMinValue() and NumberPicker.getMaxValue() values.

Protected methods
open Int

open Int

open Int

open Boolean

open Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

open Float

open Float

open Unit

open Unit
onDraw(canvas: Canvas)

open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Inherited functions