public class SortableTableView<T> extends TableView<T>
TableView
that gives the possibility to sort the table by every single
column. For this purpose implementations of Comparator
are used. If there is a comparator
set for a column the SortableTableView
will automatically display an ImageView at the start
of the header indicating to the user, that this column is sortable.
If the user clicks this header the given comparator will used to sort the table ascending by the
content of this column. If the user clicks this header again, the table is sorted descending
by the content of this column.Constructor and Description |
---|
SortableTableView(Context context)
Creates a new SortableTableView with the given context.
|
SortableTableView(Context context,
AttributeSet attributes)
Creates a new SortableTableView with the given context.
|
SortableTableView(Context context,
AttributeSet attributes,
int styleAttributes)
Creates a new SortableTableView with the given context.
|
Modifier and Type | Method and Description |
---|---|
java.util.Comparator<T> |
getColumnComparator(int columnIndex)
Gives the
Comparator of the column at the given index. |
SortStateViewProvider |
getHeaderSortStateViewProvider()
Gives the current
SortStateViewProvider . |
void |
setColumnComparator(int columnIndex,
java.util.Comparator<T> columnComparator)
Sets the given
Comparator for the column at the given index. |
void |
setHeaderSortStateViewProvider(SortStateViewProvider provider)
Sets the given
SortStateViewProvider . |
void |
sort(java.util.Comparator<T> comparator)
Sorts the table using the given
Comparator . |
void |
sort(int columnIndex)
Sorts the table by the values of the column with the given index.
|
addDataClickListener, addHeaderClickListener, getColumnCount, getColumnWeight, removeHeaderListener, removeTableDataClickListener, setColumnCount, setColumnWeight, setDataAdapter, setDataRowColoriser, setHeaderAdapter, setHeaderBackground, setHeaderBackgroundColor, setHeaderElevation
public SortableTableView(Context context)
new SortableTableView(context, null, 0
)context
- The context that shall be used.public SortableTableView(Context context, AttributeSet attributes)
new SortableTableView(context, attrs, 0
)context
- The context that shall be used.attributes
- The attributes that shall be set to the view.public SortableTableView(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.public void setColumnComparator(int columnIndex, java.util.Comparator<T> columnComparator)
Comparator
for the column at the given index. The comparator will be used for
sorting the given column.columnIndex
- The index of the column the given Comparator
shall be set to.columnComparator
- The Comparator
that shall be set to the column at the given index.public void setHeaderSortStateViewProvider(SortStateViewProvider provider)
SortStateViewProvider
.provider
- The SortStateViewProvider
that shall be used to render the sort views in the header.public SortStateViewProvider getHeaderSortStateViewProvider()
SortStateViewProvider
.SortStateViewProvider
that is currently used to render the sort views in the header.public java.util.Comparator<T> getColumnComparator(int columnIndex)
Comparator
of the column at the given index.columnIndex
- The index of the column to receive the applied Comparator
.Comparator
of the column at the given index.public void sort(int columnIndex)
sort(Comparator<T>
.columnIndex
- The index of the column on which the sorting shall be executed.public void sort(java.util.Comparator<T> comparator)
Comparator
.comparator
- The Comparator
that shall be used to sort the table.