IT. Expert System.

Android Reference

NumberPicker


android.widget

Class NumberPicker

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent


    public class NumberPicker
    extends LinearLayout
    A widget that enables the user to select a number form 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.

    For an example of using this widget, see TimePicker.

    • Constructor Detail

      • NumberPicker

        public NumberPicker(Context context)
        Create a new number picker.
        Parameters:
        context - The application environment.
      • NumberPicker

        public NumberPicker(Context context,
                    AttributeSet attrs)
        Create a new number picker.
        Parameters:
        context - The application environment.
        attrs - A collection of attributes.
      • NumberPicker

        public NumberPicker(Context context,
                    AttributeSet attrs,
                    int defStyle)
        Create a new number picker
        Parameters:
        context - the application environment.
        attrs - a collection of attributes.
        defStyle - The default style to apply to this view.
    • Method Detail

      • onLayout

        protected void onLayout(boolean changed,
                    int left,
                    int top,
                    int right,
                    int bottom)
        Description copied from class: ViewGroup
        Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.
        Overrides:
        onLayout in class LinearLayout
        Parameters:
        changed - This is a new size or position for this view
        left - Left position, relative to parent
        top - Top position, relative to parent
        right - Right position, relative to parent
        bottom - Bottom position, relative to parent
      • onInterceptTouchEvent

        public boolean onInterceptTouchEvent(MotionEvent event)
        Description copied from class: ViewGroup
        Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

        Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

        1. You will receive the down event here.
        2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
        3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
        4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action MotionEvent.ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
        Overrides:
        onInterceptTouchEvent in class ViewGroup
        Parameters:
        event - The motion event being dispatched down the hierarchy.
        Returns:
        Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.
      • onTouchEvent

        public boolean onTouchEvent(MotionEvent event)
        Description copied from class: View
        Implement this method to handle touch screen motion events.
        Overrides:
        onTouchEvent in class View
        Parameters:
        event - The motion event.
        Returns:
        True if the event was handled, false otherwise.
      • dispatchTouchEvent

        public boolean dispatchTouchEvent(MotionEvent event)
        Description copied from class: ViewGroup
        Pass the touch screen motion event down to the target view, or this view if it is the target.
        Overrides:
        dispatchTouchEvent in class ViewGroup
        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • dispatchKeyEvent

        public boolean dispatchKeyEvent(KeyEvent event)
        Description copied from class: ViewGroup
        Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
        Overrides:
        dispatchKeyEvent in class ViewGroup
        Parameters:
        event - The key event to be dispatched.
        Returns:
        True if the event was handled, false otherwise.
      • dispatchTrackballEvent

        public boolean dispatchTrackballEvent(MotionEvent event)
        Description copied from class: ViewGroup
        Pass a trackball motion event down to the focused view.
        Overrides:
        dispatchTrackballEvent in class ViewGroup
        Parameters:
        event - The motion event to be dispatched.
        Returns:
        True if the event was handled by the view, false otherwise.
      • computeScroll

        public void computeScroll()
        Description copied from class: View
        Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. This will typically be done if the child is animating a scroll using a Scroller object.
        Overrides:
        computeScroll in class View
      • setEnabled

        public void setEnabled(boolean enabled)
        Description copied from class: View
        Set the enabled state of this view. The interpretation of the enabled state varies by subclass.
        Overrides:
        setEnabled in class View
        Parameters:
        enabled - True if this view is enabled, false otherwise.
      • scrollBy

        public void scrollBy(int x,
                    int y)
        Description copied from class: View
        Move the scrolled position of your view. This will cause a call to View.onScrollChanged(int, int, int, int) and the view will be invalidated.
        Overrides:
        scrollBy in class View
        Parameters:
        x - the amount of pixels to scroll by horizontally
        y - the amount of pixels to scroll by vertically
      • getSolidColor

        public int getSolidColor()
        Description copied from class: View
        Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. Returning a non-zero color enables the view system to optimize the drawing of the fading edges. If you do return a non-zero color, the alpha should be set to 0xFF.
        Overrides:
        getSolidColor in class View
        Returns:
        The known solid color background for this view, or 0 if the color may vary
        See Also:
        View.setVerticalFadingEdgeEnabled(boolean), View.setHorizontalFadingEdgeEnabled(boolean)
      • setOnValueChangedListener

        public void setOnValueChangedListener(NumberPicker.OnValueChangeListener onValueChangedListener)
        Sets the listener to be notified on change of the current value.
        Parameters:
        onValueChangedListener - The listener.
      • setOnScrollListener

        public void setOnScrollListener(NumberPicker.OnScrollListener onScrollListener)
        Set listener to be notified for scroll state changes.
        Parameters:
        onScrollListener - The listener.
      • setFormatter

        public void setFormatter(NumberPicker.Formatter formatter)
        Set the formatter to be used for formatting the current value.

        Note: If you have provided alternative values for the values this formatter is never invoked.

        Parameters:
        formatter - The formatter object. If formatter is null, String.valueOf(int) will be used.
        See Also:
        setDisplayedValues(String[])
      • getWrapSelectorWheel

        public boolean getWrapSelectorWheel()
        Gets whether the selector wheel wraps when reaching the min/max value.
        Returns:
        True if the selector wheel wraps.
        See Also:
        getMinValue(), getMaxValue()
      • setWrapSelectorWheel

        public void setWrapSelectorWheel(boolean wrapSelectorWheel)
        Sets whether the selector wheel shown during flinging/scrolling should wrap around the getMinValue() and getMaxValue() values.

        By default if the range (max - min) is more than the number of items shown on the selector wheel the selector wheel wrapping is enabled.

        Note: If the number of items, i.e. the range ( getMaxValue() - getMinValue()) is less than the number of items shown on the selector wheel, the selector wheel will not wrap. Hence, in such a case calling this method is a NOP.

        Parameters:
        wrapSelectorWheel - Whether to wrap.
      • setOnLongPressUpdateInterval

        public void setOnLongPressUpdateInterval(long intervalMillis)
        Sets the speed at which the numbers be incremented and decremented when the up and down buttons are long pressed respectively.

        The default value is 300 ms.

        Parameters:
        intervalMillis - The speed (in milliseconds) at which the numbers will be incremented and decremented.
      • getValue

        public int getValue()
        Returns the value of the picker.
        Returns:
        The value.
      • getMinValue

        public int getMinValue()
        Returns the min value of the picker.
        Returns:
        The min value
      • setMinValue

        public void setMinValue(int minValue)
        Sets the min value of the picker.
        Parameters:
        minValue - The min value.
      • getMaxValue

        public int getMaxValue()
        Returns the max value of the picker.
        Returns:
        The max value.
      • setMaxValue

        public void setMaxValue(int maxValue)
        Sets the max value of the picker.
        Parameters:
        maxValue - The max value.
      • getDisplayedValues

        public String[] getDisplayedValues()
        Gets the values to be displayed instead of string values.
        Returns:
        The displayed values.
      • setDisplayedValues

        public void setDisplayedValues(String[] displayedValues)
        Sets the values to be displayed.
        Parameters:
        displayedValues - The displayed values.
      • getTopFadingEdgeStrength

        protected float getTopFadingEdgeStrength()
        Description copied from class: View
        Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Overrides:
        getTopFadingEdgeStrength in class View
        Returns:
        the intensity of the top fade as a float between 0.0f and 1.0f
      • getBottomFadingEdgeStrength

        protected float getBottomFadingEdgeStrength()
        Description copied from class: View
        Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.
        Overrides:
        getBottomFadingEdgeStrength in class View
        Returns:
        the intensity of the bottom fade as a float between 0.0f and 1.0f
      • onDetachedFromWindow

        protected void onDetachedFromWindow()
        Description copied from class: View
        This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
        Overrides:
        onDetachedFromWindow in class View
        See Also:
        View.onAttachedToWindow()
      • onDraw

        protected void onDraw(Canvas canvas)
        Description copied from class: View
        Implement this to do your drawing.
        Overrides:
        onDraw in class LinearLayout
        Parameters:
        canvas - the canvas on which the background will be drawn


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 10571 / 248537555. Delta: 0.06604 с