public class

SwitchFormCell

extends FormCellMetadataLayout
implements FormCell<T> InlineValidation SupportsHelperText SupportsKey
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.LinearLayout
         ↳ com.sap.cloud.mobile.fiori.formcell.FormCellMetadataLayout
           ↳ com.sap.cloud.mobile.fiori.formcell.SwitchFormCell

Class Overview

A customised Switch control which contains a TextView and a Switch allowing the user to select between two options

Structure of the control is:

  • TextView :showing the text to be displayed for label of the control See also: setKey(CharSequence)
  • Switch: showing if the property is checked or not See also:setValue(Boolean)
  • Summary

    XML Attributes
    Attribute Name Related Method Description
    SwitchFormCell_displayValueTextAppearance setValueTextAppearance(int)  
    SwitchFormCell_key  
    SwitchFormCell_keyTextAppearance setKeyTextAppearance(int)  
    SwitchFormCell_value  
    [Expand]
    Inherited XML Attributes
    From class com.sap.cloud.mobile.fiori.formcell.FormCellMetadataLayout
    [Expand]
    Inherited Constants
    From class android.widget.LinearLayout
    From class android.view.ViewGroup
    From class android.view.View
    [Expand]
    Inherited Fields
    From class com.sap.cloud.mobile.fiori.formcell.FormCellMetadataLayout
    From class android.view.View
    Public Constructors
    SwitchFormCell(Context context)
    Construct a new SwitchFormCell with default styling, sets the CellType to WidgetType.SWITCH
    SwitchFormCell(Context context, AttributeSet attrs)
    Construct a new SwitchFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType.SWITCH
    Public Methods
    int getCellType()
    Return the enum value corresponding to SwitchFormCell
    CellValueChangeListener<Boolean> getCellValueChangeListener()
    Return the value change handler of the control
    CharSequence getError()
    Get the error
    TextView getErrorView()
    CharSequence getHelperText()
    Get the helper text from the view
    CharSequence getKey()
    Get the key of the Switch FormCell
    Boolean getValue()
    Return the state of the Switch(True/False)
    boolean isEditable()
    Get if the Switch FormCell is enabled
    void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
    Taken directly from SwitchCompat and applied necessary modifications.
    boolean onInterceptTouchEvent(MotionEvent ev)
    boolean performClick()
    void setCellValueChangeListener(CellValueChangeListener<Boolean> listener)
    void setEditable(boolean isEditable)
    Set if the Switch FormCell editable
    void setError(CharSequence error)
    Set the error on the view.
    void setErrorEnabled(boolean errorEnabled)
    Enable or disable the error field on the view
    void setErrorTextAppearance(int resId)
    Set the text appearance on the error
    void setHelperEnabled(boolean enabled)
    Enable or disable the helper field on the view
    void setHelperText(CharSequence helperText)
    Set the helper text on the view
    void setHelperTextAppearance(int textAppearance)
    Set the helper text appearance
    void setKey(CharSequence keyName)
    Set the key of the switch FormCell
    void setKeyTextAppearance(int resId)
    Sets the text color, size, style, hint color, and highlight color for key from the specified TextAppearance resource.
    void setValue(Boolean value)
    Set the state of the switch whether is True or False
    void setValueTextAppearance(int resId)
    Sets the text color, size, style, hint color, and highlight color for value from the specified TextAppearance resource.
    Protected Methods
    void adjustMargins()
    Calculate and set the margins for the cell's elements.
    void onRestoreInstanceState(Parcelable state)
    Parcelable onSaveInstanceState()
    void setLabelEnabled(boolean labelEnabled)
    Enable or disable the label field on the view
    [Expand]
    Inherited Methods
    From class com.sap.cloud.mobile.fiori.formcell.FormCellMetadataLayout
    From class android.widget.LinearLayout
    From class android.view.ViewGroup
    From class android.view.View
    From class java.lang.Object
    From interface android.graphics.drawable.Drawable.Callback
    From interface android.view.KeyEvent.Callback
    From interface android.view.ViewManager
    From interface android.view.ViewParent
    From interface android.view.accessibility.AccessibilityEventSource
    From interface com.sap.cloud.mobile.fiori.formcell.FormCell
    From interface com.sap.cloud.mobile.fiori.formcell.InlineValidation
    From interface com.sap.cloud.mobile.fiori.formcell.SupportsHelperText
    From interface com.sap.cloud.mobile.fiori.formcell.SupportsKey

    XML Attributes

    SwitchFormCell_displayValueTextAppearance

    Related Methods

    SwitchFormCell_key

    Related Methods

    SwitchFormCell_keyTextAppearance

    Related Methods

    SwitchFormCell_value

    Related Methods

    Public Constructors

    public SwitchFormCell (Context context)

    Construct a new SwitchFormCell with default styling, sets the CellType to WidgetType.SWITCH

    Parameters
    context context

    public SwitchFormCell (Context context, AttributeSet attrs)

    Construct a new SwitchFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType.SWITCH

    Parameters
    context context
    attrs attribute set

    Public Methods

    public int getCellType ()

    Return the enum value corresponding to SwitchFormCell

    Returns
    • WidgetType type of the control which has implemented FormCell

    public CellValueChangeListener<Boolean> getCellValueChangeListener ()

    Return the value change handler of the control

    Returns
    • OnCellChangeListener - value change listener of the control

    public CharSequence getError ()

    Get the error

    Returns
    • CharSequence

    public TextView getErrorView ()

    public CharSequence getHelperText ()

    Get the helper text from the view

    Returns
    • CharSequence

    public CharSequence getKey ()

    Get the key of the Switch FormCell

    Returns
    • CharSequence

    public Boolean getValue ()

    Return the state of the Switch(True/False)

    Returns
    • Boolean value

    public boolean isEditable ()

    Get if the Switch FormCell is enabled

    Returns
    • boolean

    public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

    Taken directly from SwitchCompat and applied necessary modifications.

    public boolean onInterceptTouchEvent (MotionEvent ev)

    public boolean performClick ()

    public void setCellValueChangeListener (CellValueChangeListener<Boolean> listener)

    public void setEditable (boolean isEditable)

    Set if the Switch FormCell editable

    Parameters
    isEditable boolean

    public void setError (CharSequence error)

    Set the error on the view. If the view is not error enabled then this API does not take any effect.

    Parameters
    error CharSequence

    public void setErrorEnabled (boolean errorEnabled)

    Enable or disable the error field on the view

    Parameters
    errorEnabled boolean

    public void setErrorTextAppearance (int resId)

    Set the text appearance on the error

    Parameters
    resId style resource

    public void setHelperEnabled (boolean enabled)

    Enable or disable the helper field on the view

    Parameters
    enabled boolean

    public void setHelperText (CharSequence helperText)

    Set the helper text on the view

    Parameters
    helperText CharSequence

    public void setHelperTextAppearance (int textAppearance)

    Set the helper text appearance

    Parameters
    textAppearance style resource

    public void setKey (CharSequence keyName)

    Set the key of the switch FormCell

    Parameters
    keyName key of the property

    public void setKeyTextAppearance (int resId)

    Sets the text color, size, style, hint color, and highlight color for key from the specified TextAppearance resource.

    Related XML Attributes

    public void setValue (Boolean value)

    Set the state of the switch whether is True or False

    Parameters
    value value of the property

    public void setValueTextAppearance (int resId)

    Sets the text color, size, style, hint color, and highlight color for value from the specified TextAppearance resource.

    Protected Methods

    protected void adjustMargins ()

    Calculate and set the margins for the cell's elements. Subclasses should override this method to suit their own needs.

    protected void onRestoreInstanceState (Parcelable state)

    protected Parcelable onSaveInstanceState ()

    protected void setLabelEnabled (boolean labelEnabled)

    Enable or disable the label field on the view

    Parameters
    labelEnabled boolean