Skip to main content

LWUIT 1.5 Table - horizontal spanning problem

1 reply [Last post]
hajhet
Offline
Joined: 2011-08-16
Points: 0

I am wondering if this is a bug or just my faulty code. I've been trying to render table with some horizontal spanning. This is how it should look like:

In LWUIT 1.4 everything worked correctly. Since 1.5 the table looks like:

My implementation:

DefaultTableModel model = new DefaultTableModel(new String[]{"", "", "", ""}, new String[][]{
                    {"Header", null, null, null},
                    {"1", "2", "3", "4"},
                    {"1", "2", "3", "4"},
                    {"String", null, "String", null}});


Table tab = new Table(model, false) {

            protected Component createCell(Object value, final int row, final int column, boolean editable) {
                Component c = super.createCell(value, row, column, editable);
                c.setFocusable(false);
                return c;
            }

            protected TableLayout.Constraint createCellConstraint(java.lang.Object value, int row, int column) {
                TableLayout.Constraint tlay = super.createCellConstraint(value, row, column);
                if (row == 0 && column == 0) {
                    tlay.setHorizontalSpan(4);
                    tlay.setHorizontalAlign(Table.CENTER);
                } else if (row == 3)) {
                    if (column == 0) {
                        tlay.setHorizontalSpan(2);
                        tlay.setWidthPercentage(50);
                    } else if (column == 2) {
                        tlay.setHorizontalSpan(2);
                        tlay.setWidthPercentage(50);
                    }
                } else if (row != 0) {
                    tlay.setWidthPercentage(25);
                }
                return tlay;
            }

        };

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0