public class

GridObjectCell

extends FrameLayout
implements KeylineProvider
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.sap.cloud.mobile.fiori.object.GridObjectCell

Class Overview

Wrapper of GridTableRow and ObjectCell which shows GridTableRow in standard(tablet) mode, and changes to ObjectCell in compact mode. It serves as a convenient way to use GridTableRow and ObjectCell. Not all APIs in GridTableRow and ObjectCell are exposed, to further customize GridTableRow and ObjectCell, call getGridTableRow() or getObjectCell() respectively based on form factor.

Summary

Nested Classes
enum GridObjectCell.ObjectCellField ObjectCell field to be used for table columns during table to ObjectCell mapping  
XML Attributes
Attribute Name Related Method Description
com.sap.cloud.mobile.fiori:layout_columnWidth setColumnWidths(float) The column width. 
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Fields
protected List<View> mColumns
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
GridObjectCell(Context context)
GridObjectCell(Context context, AttributeSet attrs)
GridObjectCell(Context context, AttributeSet attrs, int defStyleAttr)
Public Methods
float[] getColumnWidths()
Returns the column width.
GridTableRow getGridTableRow()
Returns the wrapped GridTableRow when this class is used on a tablet.
int getKeylineStart()
Returns the keyline position which can be used to determine divider line position, etc.
ObjectCell getObjectCell()
Returns the wrapped ObjectCell when this class is used on a phone.
TextPaint getTextPaint(int index)
Returns a copy of TextPaint for column view at specified index
boolean isCompact()
Returns whether this view is running in a compact screen.
void setColumnMapping(ObjectCellField... fields)
Maps each column to a field in an ObjectCell.
void setColumnTypes(Class...<? extends View> viewTypes)
View types to be used in columns.
void setColumnWidths(float... rawColumnWidths)
Column width are laid out from start to end, until when dynamic width is specified, in which case the layout will change from end to start.
void setContents(Object... columns)
Binds content to views.
void setHeader(boolean header)
Delegates to setHeader(boolean)
void setLines(int lines)
Sets number of lines for TextView.
void setSecondaryActionOnClickListener(View.OnClickListener listener)
Sets View.OnClickListener to the secondary action icon.
void setTextPaint(int column, TextPaint textPaint)
Sets TextPaint for column view at specified index
Protected Methods
void doSetContents()
[Expand]
Inherited Methods
From class android.widget.FrameLayout
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.object.KeylineProvider

XML Attributes

com.sap.cloud.mobile.fiori:layout_columnWidth

The column width. (0-1) for percentage; [1-max] for fixed width (dp); -1 for dynamic width (only 1 dynamic column is allowed inside a row)

May be a floating point value, such as "1.2".

Related Methods

Fields

protected List<View> mColumns

Public Constructors

public GridObjectCell (Context context)

public GridObjectCell (Context context, AttributeSet attrs)

public GridObjectCell (Context context, AttributeSet attrs, int defStyleAttr)

Public Methods

public float[] getColumnWidths ()

Returns the column width. (0-1)F for percentage; [1-max]F for fixed width (dp); -1F for dynamic width (only 1 dynamic column is allowed)

public GridTableRow getGridTableRow ()

Returns the wrapped GridTableRow when this class is used on a tablet. Returns null otherwise.

See Also

public int getKeylineStart ()

Returns the keyline position which can be used to determine divider line position, etc.

Returns
  • start (left/right) position of headline text based on layout direction.

public ObjectCell getObjectCell ()

Returns the wrapped ObjectCell when this class is used on a phone. Returns null otherwise.

See Also

public TextPaint getTextPaint (int index)

Returns a copy of TextPaint for column view at specified index

Parameters
index column index
Returns
  • TextPaint object. Might be null if the column is not TextView.

public boolean isCompact ()

Returns whether this view is running in a compact screen. Useful when there is need to access underlying ObjectCell or GridTableRow.

public void setColumnMapping (ObjectCellField... fields)

Maps each column to a field in an ObjectCell. If a column should not be mapped, use NONE.

Parameters
fields GridObjectCell.ObjectCellField in order of column index

public void setColumnTypes (Class...<? extends View> viewTypes)

View types to be used in columns. Must be configured before content is set.

Parameters
viewTypes Class of views, e.g. TextView.class or ImageView.class

public void setColumnWidths (float... rawColumnWidths)

Column width are laid out from start to end, until when dynamic width is specified, in which case the layout will change from end to start. Note: 24dp padding will be allocated on left/right side of the column. Make sure to allocate enough space for each column so that it's greater than 48dp.

Parameters
rawColumnWidths (0-1)F for percentage; [1-max]F for fixed length (dp); -1F for dynamic width (only 1 dynamic column is allowed). Note: 100% can be specified as -1F.

public void setContents (Object... columns)

Binds content to views.

public void setHeader (boolean header)

Delegates to setHeader(boolean)

Parameters
header whether this row is a header

public void setLines (int lines)

Sets number of lines for TextView. No effect on a phone where ObjectCell is used.

Parameters
lines number of lines

public void setSecondaryActionOnClickListener (View.OnClickListener listener)

Sets View.OnClickListener to the secondary action icon.

public void setTextPaint (int column, TextPaint textPaint)

Sets TextPaint for column view at specified index

Parameters
column column index
textPaint custom style

Protected Methods

protected void doSetContents ()