Styling a table

21 views
Skip to first unread message

githi...@gmail.com

unread,
Apr 7, 2014, 7:37:21 AM4/7/14
to codenameone...@googlegroups.com

Hi forumners,
Referring to the attached file, I am trying to create a table that has similar look but can't seem to go past styling the Table header. I would also want to have the alternating row pattern. Any help accorded will be greatly appreciated.

Thanks.
sample table.png

Shai Almog

unread,
Apr 7, 2014, 1:15:07 PM4/7/14
to codenameone...@googlegroups.com, githi...@gmail.com
Hi,
to get the alternating colors just override the Tables createCell method as such:
protected Component createCell(Object value, int row, int column, boolean editable) {
    Component c = super.createCell(value, row, column, editable);
    if(row % 2 == 0) {
       c.setUIID("EvenCell");
    } else {
       c.setUIID("OddCell");
    }
    return c;
}

Now style odd/even cell respectively.
Reply all
Reply to author
Forward
0 new messages