-
Notifications
You must be signed in to change notification settings - Fork 7
1.2 Creating Data to display
To display data inside the FixedHeaderTableLayout
you need to create four FixedHeaderSubTableLayout
to match the four parts of Table shown below:-
The FixedHeaderSubTableLayouts
need to be created programmatically as they will usually be containing data that is derived programmatically and they would be tedious to create via XML.
FixedHeaderSubTableLayouts
can only contain FixedHeaderTableRow
objects which can then contain other view types as cells of the row.
There should be:-
- The same number of cells (columns) inside each
FixedHeaderTableRows
that make up eachFixedHeaderSubTableLayouts
- The
column Header Table
should have the same number of cells (columns) as themain Table
- The
row Header Table
should have the same number of rows as themain Table
- The
corner Header Table
should have the same number of rows as thecolumn Header Table
- The
corner Header Table
should have the same number of cells (columns) as therow Header Table
There is currently no guarantee on the behaviour of a miss shaped set to tables or protection to prevent their creation.
Empty cells should be filled with a "blank" view e.g. a Textview
with no text set.
For Example tables can be created by:-
FixedHeaderSubTableLayouts mainTable = new FixedHeaderSubTableLayout(getContext());
// 25 x 25 in size
for (int i = 1; i <=25; i++) {
FixedHeaderTableRow tableRowData = new FixedHeaderTableRow(getContext());
// Add some data
for (int j = 1; j <= 25; j++) {
// Add a Textview
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER);
textView.setText(String.format(Locale.ROOT,"C%d:R%d", j, i));
textView.setPadding(5,5,5,5);
textView.setTextSize(20.0f);
tableRowData.addView(textView);
}
// Add row to the Table
mainTable.addView(tableRowData);
}
Creating the four FixedHeaderSubTableLayouts
can take enough time that they should not be done on the UI thread, some form of background generation on another thread is advised.