1

I try to implement the third example at the link : http://devblog.blackberry.com/2009/10/how-to-use-table-view-layout/

I made a simple app to try the layout, but items do not fill the screen and stays at left side of it. I want to have the exact view of the screenshot at the example link. However my app looks like this :

enter image description here

I want the innerTable items on the right side as I pointed at the screenshot.

here is my code :

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

Do you have any idea ? Thanks

anL
  • 1,073
  • 1
  • 11
  • 31

1 Answers1

2

Try playing with each field alignment flags. for instance:

innerTable2.add(new LabelField("titleField", DrawStyle.RIGHT | Field.USE_ALL_WIDTH));
Mister Smith
  • 27,417
  • 21
  • 110
  • 193