public class TableView<T>
extends LinearLayout
TableDataAdapter
can be used.
For formatting the table headers the TableHeaderAdapter
can be used.Constructor and Description |
---|
TableView(Context context)
Creates a new TableView with the given context.
|
TableView(Context context,
AttributeSet attributes)
Creates a new TableView with the given context.
|
TableView(Context context,
AttributeSet attributes,
int styleAttributes)
Creates a new TableView with the given context.
|
Modifier and Type | Method and Description |
---|---|
void |
addDataClickListener(TableDataClickListener<T> listener)
Adds a
TableDataClickListener to this table. |
void |
addDataLongClickListener(TableDataLongClickListener<T> listener)
Adds a
TableDataLongClickListener to this table. |
void |
addHeaderClickListener(TableHeaderClickListener listener)
Adds the given
TableHeaderClickListener to this table. |
int |
getColumnCount()
Gives the number of columns of this table.
|
int |
getColumnWeight(int columnIndex)
Gives the column weight (the relative width of the column) of the given column.
|
TableDataAdapter<T> |
getDataAdapter()
Gives the
TableDataAdapter that is used to render the data view for each cell. |
TableHeaderAdapter |
getHeaderAdapter()
Gives the
TableHeaderAdapter that is used to render the header views for each column. |
boolean |
isSwipeToRefreshEnabled()
Gives information whether the swipe to refresh feature shall be enabled or not.
|
void |
removeDataClickListener(TableDataClickListener<T> listener)
Removes the given
TableDataClickListener from the click listeners of this table. |
void |
removeDataLongClickListener(TableDataLongClickListener<T> listener)
Removes the given
TableDataLongClickListener from the long click listeners of this table. |
void |
removeHeaderClickListener(TableHeaderClickListener listener)
Removes the given
TableHeaderClickListener from this table. |
void |
removeHeaderListener(TableHeaderClickListener listener)
Deprecated.
This method has been deprecated in the version 2.2.0 for naming alignment reasons. Use the method
removeHeaderClickListener(TableHeaderClickListener) instead. |
void |
removeTableDataClickListener(TableDataClickListener<T> listener)
Deprecated.
This method has been deprecated in the version 2.2.0 for naming alignment reasons. Use the method
removeDataClickListener(TableDataClickListener) instead. |
void |
setColumnCount(int columnCount)
Sets the number of columns of this table.
|
void |
setColumnWeight(int columnIndex,
int columnWeight)
Sets the column weight (the relative width of the column) of the given column.
|
void |
setDataAdapter(TableDataAdapter<T> dataAdapter)
Sets the
TableDataAdapter that is used to render the data view for each cell. |
void |
setDataRowBackgroundProvider(TableDataRowBackgroundProvider<? super T> backgroundProvider)
Sets the given
TableDataRowBackgroundProvider that will be used to define the background color for
every table data row. |
void |
setDataRowColorizer(TableDataRowColorizer<? super T> colorizer)
Deprecated.
This method is deprecated. Use
setDataRowBackgroundProvider(de.codecrafters.tableview.providers.TableDataRowBackgroundProvider<? super T>) instead. |
void |
setHeaderAdapter(TableHeaderAdapter headerAdapter)
Sets the
TableHeaderAdapter that is used to render the header views for each column. |
void |
setHeaderBackground(int resId)
Sets the given resource as background of the table header.
|
void |
setHeaderBackgroundColor(int color)
Sets the given color as background of the table header.
|
void |
setHeaderElevation(int elevation)
Sets the elevation level of the header view.
|
protected void |
setHeaderView(de.codecrafters.tableview.TableHeaderView headerView)
Replaces the default
TableHeaderView with the given one. |
void |
setSaveEnabled(boolean enabled) |
void |
setSwipeToRefreshEnabled(boolean enabled)
Toggles the swipe to refresh feature to the user.
|
void |
setSwipeToRefreshListener(SwipeToRefreshListener listener)
Sets the
SwipeToRefreshListener for this table view. |
public TableView(Context context)
new TableView(context, null, android.R.attr.listViewStyle
)context
- The context that shall be used.public TableView(Context context, AttributeSet attributes)
new TableView(context, attrs, android.R.attr.listViewStyle
)context
- The context that shall be used.attributes
- The attributes that shall be set to the view.public TableView(Context context, AttributeSet attributes, int styleAttributes)
context
- The context that shall be used.attributes
- The attributes that shall be set to the view.styleAttributes
- The style attributes that shall be set to the view.protected void setHeaderView(de.codecrafters.tableview.TableHeaderView headerView)
TableHeaderView
with the given one.headerView
- The new TableHeaderView
that should be set.public void setSwipeToRefreshEnabled(boolean enabled)
enabled
- Whether the swipe to refresh feature shall be enabled or not.public boolean isSwipeToRefreshEnabled()
public void setSwipeToRefreshListener(SwipeToRefreshListener listener)
SwipeToRefreshListener
for this table view. If there is already a SwipeToRefreshListener
set it will be replaced.listener
- The SwipeToRefreshListener
that is called when the user triggers the refresh action.public void setHeaderBackground(@DrawableRes int resId)
resId
- The if of the resource tht shall be set as background of the table header.public void setHeaderBackgroundColor(int color)
color
- The color that shall be set as background of the table header.public void setHeaderElevation(int elevation)
elevation
- The elevation that shall be set to the table header.@Deprecated public void setDataRowColorizer(TableDataRowColorizer<? super T> colorizer)
setDataRowBackgroundProvider(de.codecrafters.tableview.providers.TableDataRowBackgroundProvider<? super T>)
instead.TableDataRowColorizer
that will be used to define the background color for
every table data row.colorizer
- The TableDataRowColorizer
that shall be used.public void setDataRowBackgroundProvider(TableDataRowBackgroundProvider<? super T> backgroundProvider)
TableDataRowBackgroundProvider
that will be used to define the background color for
every table data row.backgroundProvider
- The TableDataRowBackgroundProvider
that shall be used.public void addDataClickListener(TableDataClickListener<T> listener)
TableDataClickListener
to this table. This listener gets notified every time the user clicks
a certain data item.listener
- The listener that should be added as click listener.public void addDataLongClickListener(TableDataLongClickListener<T> listener)
TableDataLongClickListener
to this table. This listener gets notified every time the user clicks
long on a certain data item.listener
- The listener that should be added as long click listener.@Deprecated public void removeTableDataClickListener(TableDataClickListener<T> listener)
removeDataClickListener(TableDataClickListener)
instead.TableDataClickListener
from the click listeners of this table.listener
- The listener that should be removed.public void removeDataClickListener(TableDataClickListener<T> listener)
TableDataClickListener
from the click listeners of this table.listener
- The listener that should be removed.public void removeDataLongClickListener(TableDataLongClickListener<T> listener)
TableDataLongClickListener
from the long click listeners of this table.listener
- The listener that should be removed.public void addHeaderClickListener(TableHeaderClickListener listener)
TableHeaderClickListener
to this table.listener
- The listener that shall be added to this table.@Deprecated public void removeHeaderListener(TableHeaderClickListener listener)
removeHeaderClickListener(TableHeaderClickListener)
instead.TableHeaderClickListener
from this table.listener
- The listener that shall be removed from this table.public void removeHeaderClickListener(TableHeaderClickListener listener)
TableHeaderClickListener
from this table.listener
- The listener that shall be removed from this table.public TableHeaderAdapter getHeaderAdapter()
TableHeaderAdapter
that is used to render the header views for each column.TableHeaderAdapter
that is currently set.public void setHeaderAdapter(TableHeaderAdapter headerAdapter)
TableHeaderAdapter
that is used to render the header views for each column.headerAdapter
- The TableHeaderAdapter
that should be set.public TableDataAdapter<T> getDataAdapter()
TableDataAdapter
that is used to render the data view for each cell.TableDataAdapter
that is currently set.public void setDataAdapter(TableDataAdapter<T> dataAdapter)
TableDataAdapter
that is used to render the data view for each cell.dataAdapter
- The TableDataAdapter
that should be set.public int getColumnCount()
public void setColumnCount(int columnCount)
columnCount
- The number of columns.public void setColumnWeight(int columnIndex, int columnWeight)
columnIndex
- The index of the column the weight should be set to.columnWeight
- The weight that should be set to the column.public int getColumnWeight(int columnIndex)
columnIndex
- The index of the column the weight should be returned.public void setSaveEnabled(boolean enabled)