Skip to content

Commit aa0b533

Browse files
author
Ingo Schwarz
committed
Add docs about TableColumnModel to readme
1 parent b072eb6 commit aa0b533

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

README.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,28 @@ A second possibility to define the column count of your TableView is to set it d
4141
```
4242

4343
#### Column Width
44-
To define the relative width of your columns you can define a specific *weight* for each of them (as you may know from [LinearLayout](http://developer.android.com/guide/topics/ui/layout/linear.html)). By default the weight of each column is set to 1. So every column has the same width. To make the first column (index of first column is 0) twice as wide as the other columns simple do the following call.
44+
To define the column widths you can set a `TableColumnModel` that defines the width for each column. You can use a
45+
predefined `TableColumnModel` or implement your custom one.
46+
47+
**TableColumnWeightModel**
48+
This model defines the column widths in a relative manner. You can define a weight for each column index.
49+
The default column weight is 1.
4550
```java
46-
tableView.setColumnWeight(0, 2);
51+
TableColumnWeightModel columnModel = new TableColumnWeightModel(4);
52+
columnModel.setColumnWeight(1, 2);
53+
columnModel.setColumnWeight(2, 2);
54+
tableView.setColumnModel(columnModel);
55+
```
56+
57+
**TableColumnWidthModel**
58+
This model defines the column widths in a absolute manner. You can define a width in pixels for each column index.
59+
The default column width is 200px. You can pass a different default to the constructor.
60+
```
61+
TableColumnWidthModel columnModel = new TableColumnWidthModel(4, 350);
62+
columnModel.setColumnWidth(1, 500);
63+
columnModel.setColumnWidth(2, 600);
64+
tableView.setColumnModel(columnModel);
4765
```
48-
Because the width of an column is not given absolute but relative, the TableView will adapt to all screen sizes.
4966

5067
### Showing Data
5168
#### Simple Data

0 commit comments

Comments
 (0)