LWUIT 1.5表 - 水平跨越布局

问题描述 投票:3回答:2

我想知道这是一个错误还是我的错误代码。我一直试图用一些水平跨度来渲染表格。它应该是这样的:

在LWUIT 1.4中,一切正常。从1.5开始,表格如下:

我的实施:

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;
        }

    };
java-me tablelayout lwuit
2个回答
1
投票

错误(在LWUIT中)由tlay.setWidthPercentage(50);触发,你可以删除它并仍然得到预期的结果。似乎宽度百分比值不考虑我猜它应该考虑的范围。

您应该在问题跟踪器中为此提交错误,感谢您的错误。


0
投票

我添加了这一行

TableLayout.setDefaultColumnWidth(1);

之前

Table tab = new Table(model, false) {
...

它成功了。

© www.soinside.com 2019 - 2024. All rights reserved.