Class: Toybox.WatchUi.SimpleDataField
- Inherits:
-
Toybox.WatchUi.DataField
Overview
Create a SimpleDataField.
A SimpleDataField is a special View that automatically provides Activity.Info once per second via the compute() method.
Just like in a DataField, a SimpleDataField automatically provides Activity.Info once per second via the compute() method. In exchange for the flexibility offered in a DataField, all field layout is handled automatically in a SimpleDataField.
A SimpleDataField requires two items:
-
A compute() method should return the value to be displayed by the SimpleDataField. Allowed types are Number, Float, Long, Double, Duration, and String.
-
A "label" variable, which should be assigned a String label for the field.
See Also:
The system will call the onUpdate() method inherited from View when a Data Field is displayed by the system. Because compute() and onUpdate() are asynchronous, there is no guarantee that compute() will be called before onUpdate(). For this reason, variables should never be initialized in compute().
Instance Member Summary collapse
-
label as Lang.String
The field label String.
Instance Method Summary collapse
-
compute(info as Activity.Info) as Lang.Numeric or Time.Duration or Lang.String or Null
Retrieve Activity.Info in a SimpleDataField.
-
initialize()
Constructor.
Instance Attribute Details
var label as Lang.String
The field label String.
Instance Method Details
compute(info as Activity.Info) as Lang.Numeric or Time.Duration or Lang.String or Null
Retrieve Activity.Info in a SimpleDataField.
This method is called once per second and automatically provides
Activity.Info to the SimpleDataField object
for display or additional computation. It is necessary to override
compute()
when implementing a SimpleDataField. The value to be
displayed in the field must be returned by this method.
initialize()
Constructor