}));
tableView.setController(tableController);
// Create a DataTemplate that suppresses the third column
final DataTemplate dataTemplate = new DataTemplate(tableView, 2, 3) {
/**
* @see DataTemplate#getDataFields(int)
*/
public Field[] getDataFields(final int modelRowIndex) {
final Object[] data =
(Object[]) ((TableModel) getView().getModel())
.getRow(modelRowIndex);
final Field[] fields = new Field[4];
fields[0] = new BitmapField((Bitmap) data[0]);
fields[1] =
new LabelField(data[1], Field.FOCUSABLE
| DrawStyle.HCENTER);
fields[2] = new LabelField(data[3], Field.FOCUSABLE);
fields[3] = new LabelField(data[4], Field.FOCUSABLE);
return fields;
}
};
// Set up regions
dataTemplate.createRegion(new XYRect(0, 0, 1, 2), style);
dataTemplate.createRegion(new XYRect(1, 0, 2, 1), style);
dataTemplate.createRegion(new XYRect(1, 1, 1, 1), style);
dataTemplate.createRegion(new XYRect(2, 1, 1, 1), style);
// Specify the size of each column by percentage, and the height of a
// row
dataTemplate.setColumnProperties(0, new TemplateColumnProperties(15,
TemplateColumnProperties.PERCENTAGE_WIDTH));
dataTemplate.setColumnProperties(1, new TemplateColumnProperties(15,
TemplateColumnProperties.PERCENTAGE_WIDTH));
dataTemplate.setColumnProperties(2, new TemplateColumnProperties(70,
TemplateColumnProperties.PERCENTAGE_WIDTH));
dataTemplate.setRowProperties(0, new TemplateRowProperties(ROW_HEIGHT));
dataTemplate.setRowProperties(1, new TemplateRowProperties(ROW_HEIGHT));
// Apply the template to the view
tableView.setDataTemplate(dataTemplate);
dataTemplate.useFixedHeight(true);
add(tableView);
}