Skip to content

The Simple Property Form Cell

The simple property form cell represents a key value cell in which the value is a single line editable text field. This cell also supports facilities to set helper or error texts.

Using the Simple Property Form Cell

The simple property form cell can be used within your activity like any traditional Android view:

1
2
3
4
5
6
<com.sap.cloud.mobile.fiori.formcell.SimplePropertyFormCell
        android:id="@+id/SimplePropertyFormCell1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:key="Cell key"
        app:value="Cell value" />

Editable and Non-Editable Modes

Like other form cells, this form cell can also be set to editable or non-editable modes. A non-editable cell is enabled but the value field on the cell is not editable. By default, the simply property form cell is editable. 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:

1
2
       SimplePropertyFormCell mSimplePropertyCell = findViewById(R.id.simpleproperty_formcell);
       mSimplePropertyCell.setIsEditable(false);
For more information about the editable attribute, see FormCell.

Error and Helper Texts

To set the error and helper text on the view, enable the feature on the view by calling setErrorEnabled and setHelperEnabled respectively. You can also use "app:errorEnabled" and "app:helperEnabled" XML attributes to enable the support for these features. Once enabled, you can call setError(CharSequence) to set the error text and setHelperText to set the helper text. Once set, the error/helper text remains enabled, until setErrorEnabled(false)/setHelperEnabled(false) is called.

Text Selectable

The simply property form cell also allows you to enable or disable the ability to select the value text in non-editable states. You can check different variants in action at NoteFormCell Demo

Listening for Cell Value Changes

To listen for updates to the cell value, attach a CellValueChangeListener\ using setCellValueChangeListener:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mSimplePropertyFormCell.setCellValueChangeListener(new FormCell.CellValueChangeListener<CharSequence>() {
            @Override
            protected void cellChangeHandler(@NonNull CharSequence value) {
                if (value.length() > 20) {
                    mSimplePropertyFormCell1.setErrorEnabled(true);
                    mSimplePropertyFormCell1.setError("This is too long value");
                } else {
                    mSimplePropertyFormCell1.setErrorEnabled(false);
                }
            }
        });

Also see FormCell