New to Telerik UI for Xamarin? Download free 30-day trial

NumberPicker for Xamarin.Android: Getting Started

To use RadNumberPicker a dependency to the Telerik.Xamarin.Android.Input.dll library must be added.

Creating RadNumberPicker is like creating any other widget:

RadNumberPicker picker = new RadNumberPicker(context);

RadNumberPicker can be customized with the following properties:

  • Value - Setting the value outside the [minimum, maximum] range will result in the value being clamped to that range.
  • Step - Defines the step by which the value will increase when the plus and minus buttons are pressed. If the [min, max] range is not divisible by the step the number picker will not be able to reach the maximum or minimum value.
  • Minimum - Defines the max value of the number picker. The Value can never become more than max.
  • Maximum - Defines the min value of the number picker. The Value can never become less than min.
  • FormatString - The format string can be used to specify specific text for RadNumberPicker. The format string functionality is actually composed of three sub properties. These are SingleFormatString, PluralFormatString and ZeroFormatString. When RadNumberPicker's value is equal to 1 SingleFormatString will be used, ZeroFormatString for 0 and for the rest of the values PluralFormatString will be used.

Finally RadNumberPicker has AddPropertyChangeListener() and RemovePropertyChangedListener() methods that can be used to listen for changes in the number picker. For example to listen for value changes the following code is in order:

picker.AddPropertyChangedListener(new MyPropertyChangedListener());

public class MyPropertyChangedListener : Java.Lang.Object, IPropertyChangedListener {
    public void OnPropertyChanged (string propertyName, Java.Lang.Object value)
    {
        if(propertyName.Equals("Value")) {
            double newValue = (Double)value;
            // do something with the new value.
        }
    }
}
In this article