如何使用TableLayoutManager用项目填充屏幕

时间:2013-04-01 14:14:16

标签: blackberry blackberry-jde

我尝试在链接上实现第三个示例:http://devblog.blackberry.com/2009/10/how-to-use-table-view-layout/

我制作了一个简单的应用程序来尝试布局,但是项目没有填满屏幕并停留在它的左侧。我希望在示例链接中获得截图的确切视图。但是我的应用程序看起来像这样:

enter image description here

当我指向屏幕截图时,我想要右侧的innerTable项目。

这是我的代码:

TableLayoutManager outerTable = new TableLayoutManager(new int[]{
        TableLayoutManager.USE_PREFERRED_SIZE,
        TableLayoutManager.SPLIT_REMAINING_WIDTH
       },USE_ALL_WIDTH);

TableLayoutManager innerTable = new TableLayoutManager(new int[]{
                TableLayoutManager.USE_PREFERRED_SIZE,
                TableLayoutManager.USE_PREFERRED_SIZE
               },TableLayoutManager.USE_ALL_WIDTH);
TableLayoutManager innerTable2 = new TableLayoutManager(new int[]{
                TableLayoutManager.USE_PREFERRED_SIZE,
                TableLayoutManager.USE_PREFERRED_SIZE
               },0);


innerTable.add(new LabelField("titleField"));
innerTable.add(new LabelField("title"));
innerTable.add(new LabelField("descriptionfield"));
innerTable.add(new LabelField("description"));
innerTable.add(new LabelField("rating field"));
innerTable.add(new LabelField("***"));
outerTable.add(new BitmapField(Bitmap.getBitmapResource("testimg.png"),Field.FOCUSABLE));
outerTable.add(innerTable);


innerTable2.add(new LabelField("titleField"));
innerTable2.add(new LabelField("title"));
innerTable2.add(new LabelField("descriptionfield"));
innerTable2.add(new LabelField("description"));
innerTable2.add(new LabelField("rating field"));
innerTable2.add(new LabelField("***"));
outerTable.add(new BitmapField(Bitmap.getBitmapResource("testimg.png"),Field.FOCUSABLE));
outerTable.add(innerTable2);
add(outerTable);
你知道吗? 感谢

1 个答案:

答案 0 :(得分:2)

尝试使用每个字段对齐标记。例如:

innerTable2.add(new LabelField("titleField", DrawStyle.RIGHT | Field.USE_ALL_WIDTH));