SkillAgentSearch skills...

SortableTableView

An Android library containing a simple TableView and an advanced SortableTableView providing a lot of customisation possibilities to fit all needs.

Install / Use

/learn @ISchwarz23/SortableTableView
About this skill

Quality Score

0/100

Category

Design

Supported Platforms

Universal

README

Android Arsenal API Build Status

SortableTableView for Android

An Android library providing a TableView and a SortableTableView.

SortableTableView Example

Minimum SDK-Version: 11 |  Compile SDK-Version: 25 |  Latest Library Version: 2.8.0  

New version available! Check version 3.1.0 of the pro version.

Repository Content

tableview - contains the android library sources and resources
app - contains an example application showing how to use the SortableTableView

Example App

Setup

Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Then add the dependency:

    dependencies {
        ...
        implementation 'com.github.ISchwarz23:SortableTableView:2.8.1'
        ...
    }

Pro Version

If you want to have the best TableView experience, we offer you the possibility to get the pro version of the SortableTableView. This is what the pro version offers you:

| | Open-Source Version | Pro Version | | --- | --- | --- | | render simple data | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | render custom data | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | header styling | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | data row styling | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | data sorting | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | data loading | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | searching | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | paging | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | selection | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | view recycling | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | support | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | maintenance | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | quick start guide | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> | | full documentation | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/cross-mark_274c.png" height="24"> | <img src="https://emojipedia-us.s3.amazonaws.com/thumbs/120/microsoft/106/heavy-check-mark_2714.png" height="24"> |

To get more information visit the SortableTableView-Page.

<!--- ## Support the open-source version As the open-source version brings a lot of work to maintain, you can support me with a small donation in order to keep the free version alive. *"Thank's for creating this project, here's a coffee (or some beer) for you!"* [Donate 5$](https://www.paypal.me/ISchwarz23/5USD) or [Donate 5€](https://www.paypal.me/ISchwarz23/5EUR) *"Wow, I am stunned. Let me take you to the movies!"* [Donate 10$](https://www.paypal.me/ISchwarz23/10USD) or [Donate 10€](https://www.paypal.me/ISchwarz23/10EUR) *"I really appreciate your work, let's grab some lunch!"* [Donate 15$](https://www.paypal.me/ISchwarz23/15USD) or [Donate 15€](https://www.paypal.me/ISchwarz23/15EUR) *"That's some awesome stuff you did right there, dinner is on me!"* [Donate 25$](https://www.paypal.me/ISchwarz23/25USD) or [Donate 25€](https://www.paypal.me/ISchwarz23/25EUR) *"I really really want to support this project, great job!"* [Donate 50$](https://www.paypal.me/ISchwarz23/50USD) or [Donate 50€](https://www.paypal.me/ISchwarz23/50EUR) *"You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!"* [Donate 100$](https://www.paypal.me/ISchwarz23/100USD) or [Donate 100€](https://www.paypal.me/ISchwarz23/100EUR) --->

Features

Layouting

Column Count

The provided TableView is very easy to adapt to your needs. To set the column count simple set the parameter inside your XML layout.

<de.codecrafters.tableview.TableView
    xmlns:table="http://schemas.android.com/apk/res-auto"
    android:id="@+id/tableView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    table:tableView_columnCount="4" />

A second possibility to define the column count of your TableView is to set it directly in the code.

TableView tableView = (TableView) findViewById(R.id.tableView);
tableView.setColumnCount(4);

Column Width

To define the column widths you can set a TableColumnModel that defines the width for each column. You can use a predefined TableColumnModel or implement your custom one.

TableColumnWeightModel
This model defines the column widths in a relative manner. You can define a weight for each column index. The default column weight is 1.

TableColumnWeightModel columnModel = new TableColumnWeightModel(4);
columnModel.setColumnWeight(1, 2);
columnModel.setColumnWeight(2, 2);
tableView.setColumnModel(columnModel);

TableColumnDpWidthModel
This model defines the column widths in a absolute manner. You can define a width in density-independent pixels for each column index. The default column width is 100dp. You can pass a different default to the constructor.

TableColumnDpWidthModel columnModel = new TableColumnDpWidthModel(context, 4, 200);
columnModel.setColumnWidth(1, 300);
columnModel.setColumnWidth(2, 250);
tableView.setColumnModel(columnModel);

TableColumnPxWidthModel
This model defines the column widths in a absolute manner. You can define a width in pixels for each column index. The default column width is 200px. You can pass a different default to the constructor.

TableColumnPxWidthModel columnModel = new TableColumnPxWidthModel(4, 350);
columnModel.setColumnWidth(1, 500);
columnModel.setColumnWidth(2, 600);
tableView.setColumnModel(columnModel);

Showing Data

Simple Data

For displaying simple data like a 2D-String-Array you can use the SimpleTableDataAdapter. The SimpleTableDataAdapter will turn the given Strings to TextViews and display them inside the TableView at the same position as previous in the 2D-String-Array.

public class MainActivity extends AppCompatActivity {
    
    private static final String[][] DATA_TO_SHOW = { { "This", "is", "a", "test" }, 
                                                     { "and", "a", "second", "test" } };
        
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TableView<String[]> tableView = (TableView<String[]>) findViewById(R.id.tableView);
        tableView.setDataAdapter(new SimpleTableDataAdapter(this, DATA_TO_SHOW));
    }
}        

Custom Data

For displaying more complex custom data you need to implement your own TableDataAdapter. Therefore you need to implement the getCellView(int rowIndex, int columnIndex, ViewGroup parentView) method. This method is called for eve

View on GitHub
GitHub Stars1.1k
CategoryDesign
Updated5d ago
Forks239

Languages

Java

Security Score

100/100

Audited on Mar 23, 2026

No findings