Choice Form Cell¶
The choice form cell allows the user to select a single value from a group of values. It uses Material Design Chips to display the set of values. Selecting a single chip automatically deselects all other chips in the set in the same way radio buttons work.
Placement¶
By default the chips are displayed on a single line that scrolls horizontally:
The chips can also wrap on to multiple lines:
The boolean
attribute singleLine
determines how the chips are placed.
Appearance¶
By default chips are displayed with a filled background:
Chips can also be displayed with an outlined border:
The boolean
attribute outlined
determines if chips are outlined.
Using Choice Form Cell¶
Choice form cell can be placed within your activity like any traditional Android view:
<com.sap.cloud.mobile.fiori.formcell.ChoiceFormCell
android:id="@+id/choiceCell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:key="Test ChoiceFormCell"
app:value="1"
app:outlined="false"
app:singleLine="true"
android:entries="@array/tabValuesArray" />
Callback Mechanism¶
Choice form cell supports callback listeners, such as OnCellChangeListener<Integer>
, to notify the application of changes to the selected choice.
The OnCellChangeListener<Integer>
callback is called whenever a different chip is selected.
mChoiceFormCell = findViewById(R.id.choiceCell);
mChoiceFormCell.setCellValueChangeListener(new FormCell.CellValueChangeListener<Integer>() {
@Override
public void cellChangeHandler(Integer value) {
// Value represents the nth chip in the set.
// Do something with value...
}
});