0

I use table In one of my codenameone application forms.

I've a problem on column width. In some devices the table shows with horizontal scroll but in some devices not. I wanna fit the table to device screen width or change some columns width. I was searching for this feature but I didn't find something proper.

How can it perform?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ahmad
  • 437
  • 5
  • 20

2 Answers2

1

You can use the width attribute, it is expressed in percentage of available space where -1 is a special case (use it only on one column) that takes up remaining available space.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks Shai Almog, I wanna do it with code in run-time mode not in design mode. How it done? I didn't find something proper. – Ahmad Apr 18 '13 at 08:06
  • If you are using the table layout then just add elements with the additional Table.Constraint argument you can get by using the TableLayout.createConstraint() method. If you are using the Table class then override protected TableLayout.Constraint createCellConstraint(Object value, int row, int column) in the Table – Shai Almog Apr 18 '13 at 18:58
  • Is there any sample that show these capability completely? I tried to use it but nothing is clear. Thanks Shai. – Ahmad Apr 20 '13 at 04:58
  • And where can I change the Width of one column in TableLayout or Table? I have 4 column and I wanna size them the with different size. – Ahmad Apr 20 '13 at 05:33
  • TableLayout l = ...; TableLayout.Constraint c = l.createConstraint(); c.setWidth(...); – Shai Almog Apr 20 '13 at 18:31
-2

My advice is to checkout jquerymobile's solution [enter link description here][1]

[1]: http://jquerymobile.com/demos/1.3.0-beta.1/docs/tables/table-reflow.html jquerymobile reflow table

SuperManSL
  • 1,306
  • 2
  • 12
  • 17