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:isEditable="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
}
});
Required Field¶
The duration picker form cell can be marked as a required field by passing true to the setIsRequired() method or setting the isRequired XML attribute to true. This will add an asterisk (*) at the end of the label, to indicate that the duration must be set. Note that this does not validate whether the duration has been set or not. To validate the requirement, refer to Error and Helper Text.
DurationPickerFormCell durationCellRequired = findViewById(R.id.durationCellRequired);
durationCellRequired.setIsRequired(true);
<com.sap.cloud.mobile.fiori.formcell.DurationPickerFormCell
android:id="@+id/durationCellRequired"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:key="Required Duration Picker"
app:isRequired="true"/>
The required indicator can also be customized by passing a character to the setRequiredIndicator() method which will replace the asterisk with the character that is passed to the method. The indicator's color can also be changed by passing a color to the setRequiredIndicatorColor() method or the requiredIndicatorColor XML attribute.
DurationPickerFormCell durationCellRequired = findViewById(R.id.durationCellRequired);
durationCellRequired.setIsRequired(true);
durationCellRequired.setRequiredIndicator('ยน');
durationCellRequired.setRequiredIndicatorColor(Color.RED);
<com.sap.cloud.mobile.fiori.formcell.DurationPickerFormCell
android:id="@+id/durationCellRequired"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:key="Required Duration Picker"
app:isRequired="true"
app:requiredIndicatorColor="@color/red"/>
Inline AI Notice¶
The Inline AI Notice is shown when displaying generative content, such as suggestions for a duration selection. An onClick listener for handling hyperlink click events must also be provided. See InlineNotice for more details.
DurationPickerFormCell durationCell = findViewById(R.id.durationCell);
durationCell.setInlineNoticeEnabled(true);
durationCell.setInlineNoticeHyperlinkOnClick(v -> {});

Also see FormCell