Added in API level 30

RangeTemplate


class RangeTemplate : ControlTemplate
kotlin.Any
   ↳ android.service.controls.templates.ControlTemplate
   ↳ android.service.controls.templates.RangeTemplate

A template for a Control with inputs in a "continuous" range of values.

Summary

Inherited constants
Public constructors
RangeTemplate(templateId: String, minValue: Float, maxValue: Float, currentValue: Float, stepValue: Float, formatString: CharSequence?)

Construct a new RangeTemplate.

Public methods
Float

The current value for this range.

CharSequence

Formatter for generating a user visible String representing the value returned by RangeTemplate.getCurrentValue.

Float

The maximum value for this range.

Float

The minimum value for this range.

Float

The value of the smallest increment or decrement that can be performed on this range.

Int

Inherited functions

Public constructors

RangeTemplate

Added in API level 30
RangeTemplate(
    templateId: String,
    minValue: Float,
    maxValue: Float,
    currentValue: Float,
    stepValue: Float,
    formatString: CharSequence?)

Construct a new RangeTemplate. The range must be valid, meaning:

  • minValue < maxValue
  • minValue < currentValue
  • currentValue < maxValue
  • 0 < stepValue

The current value of the Control will be formatted accordingly.

Parameters
templateId String: the identifier for this template object This value cannot be null.
minValue Float: minimum value for the input
maxValue Float: maximum value for the input
currentValue Float: the current value of the Control containing this object.
stepValue Float: minimum value of increments/decrements when interacting with this control.
formatString CharSequence?: a formatting string as per java.lang.String#format used to display the currentValue. If null is passed, the "%.1f" is used.
Exceptions
java.lang.IllegalArgumentException if the parameters passed do not make a valid range.

Public methods

getCurrentValue

Added in API level 30
fun getCurrentValue(): Float

The current value for this range.

getFormatString

Added in API level 30
fun getFormatString(): CharSequence

Formatter for generating a user visible String representing the value returned by RangeTemplate.getCurrentValue.

Return
CharSequence a formatting string as specified in java.lang.String#format This value cannot be null.

getMaxValue

Added in API level 30
fun getMaxValue(): Float

The maximum value for this range.

getMinValue

Added in API level 30
fun getMinValue(): Float

The minimum value for this range.

getStepValue

Added in API level 30
fun getStepValue(): Float

The value of the smallest increment or decrement that can be performed on this range.

getTemplateType

Added in API level 30
fun getTemplateType(): Int
Return
Int ControlTemplate.TYPE_RANGE