-
Notifications
You must be signed in to change notification settings - Fork 20
07 NumberPickerPreference
Michael Rapp edited this page Dec 29, 2017
·
2 revisions
The purpose of the class NumberPickerPreference is to provide a preference implementation, which allows to choose a decimal number by using a NumberPicker widget. Such a widget allows to scroll through the range of possible numbers.
The library's API provides the following getter and setter methods in order to adjust the properties of a NumberPickerPreference programmatically. Furthermore, the methods of the base class DialogPreference can also be used.
| Getter and setter methods | Description | Default value | Restrictions |
|---|---|---|---|
getNumber():int setNumber(int):void
|
Returns or sets the currently persisted number of the preference. If a number is set, it is instantly persisted. | 0 |
The number must be at least the minimum number and at maximum the maximum number. |
isInputMethodUsed():boolean useInputMethod(boolean):void
|
Returns or sets, whether it is possible to enter a number by using the keyboard, or not. | false |
none |
isSelectorWheelWrapped():boolean wrapSelectorWheel(boolean):void
|
Returns or sets, whether the NumberPicker's selector wheel is wrapped, or not. |
true |
none |
getMinNumber():int setMinNumber(int):void
|
Returns or sets the minimum number, the preference allows to choose. | 0 |
The minimum number must be less than the maximum number. |
getMaxNumber():int setMaxNumber(int):void
|
Returns or sets the maximum number, the preference allows to choose. | 10 |
The maximum number must be greater than the minimum number. |
getUnit():CharSequence setUnit(CharSequence):void setUnit(int):void
|
Returns or sets the unit, which is appended to the preference's currently chosen number for textual representation. It the unit is set to null, no unit is appended. | null |
none |
getStepSize():int setStepSize(int):void
|
Returns or sets the step size, the number is increased or decreased by, when the user moves the preference's selector wheel. | 1 |
The value must be at minimum 1 and at maximum the value of the method getRange(). |
Alternatively, the properties, which can be set by the using the setter methods, which have been discussed in the previous section, can be specified by using XML attributes. The following attributes are available.
| XML attribute | Description | Format |
|---|---|---|
android:defaultValue |
The default number of the preference. | integer |
custom:useInputMethod |
Whether it should be possible to enter a number by using the keyboard, or not. | boolean |
custom:min |
The minimum number, the preference allows to choose. | integer |
android:max |
The maximum number, the preference allows to choose. | integer |
custom:unit |
The unit, which is appended to the preference's current number for textual representation. If the unit is null, no unit is appended. | string |
custom:stepSize |
The step size the preference's current number is increased or decreased by, when the user moves the selector wheel. | integer |