Duration Picker Form Cell¶
The duration picker form cell represents a key value cell where the value is a date. Like other form cells, this cell also supports facilities to set helper or error texts.
Using the Duration Picker Form Cell¶
This form cell can be used within your activity like any traditional Android view:
<com.sap.cloud.mobile.fiori.formcell.DurationPickerFormCell
android:id="@+id/durationCell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/FioriTheme.Picker"
app:dialogTitle="Yoga Time!" />
Editable and Non-Editable Modes¶
The duration picker form cell can be set to editable or non-editable modes. For this form cell, editable and enabled attributes are same: a non-editable duration picker form cell is not enabled (not clickable, not focusable
). By default, this form cell is editable and enabled. You can control the editability of the cell by using XML attribute app:editable="false
. You can also fetch the view in your activity and set it to be editable:
DurationPickerFormCell durationCell = findViewById(R.id.durationCell);
durationCell.setIsEditable(false);
For more information about the editable attribute, see FormCell
.
Title¶
The duration picker form cell supports a title field on the Duration Picker dialog. You can set the title using android app:dialogTitle
XML attribute.
DateFormatter
¶
You may want to change the format of the duration displayed to a user based on locale or some other logic. To change the format, set the Duration Formatter using setDurationTextFormat(String)
API on the cell. As shown below, cell values presented to the user are first formatted using your duration formatter.
Error and Helper Text¶
Follow design guidelines and see: FormCell
Listening for Cell Value Changes¶
To listen for updates to a cell value, attach a CellValueChangeListener
using setCellValueChangeListener
.
mDurationCell.setCellValueChangeListener(new FormCell.CellValueChangeListener<Duration>() {
@Override
protected void cellChangeHandler(@NonNull Duration value) {
// Application logic here
}
});
Also see FormCell