Search code examples
blackberrytablemodel

Add simple table with text to screen


How do I add a simple plain table with data to existing screen?

The data is already parsed text from DOM. Can I do it with TableModel? Here's what I have now:

TableModel tm = new TableModel();
tm.addRow(doc.getElementsByTagName("id").item(0).getChildNodes().item(0).getNodeValue());
tm.addRow(doc.getElementsByTagName("id").item(1).getChildNodes().item(0).getNodeValue());

final MyScreen screen = new MyScreen();

Can I use something like:

screen.add(...)

Or it should I use something other than the TableModel container?


Solution

  • TableModel is merely a data model. To display the data, you'll need to use a Field that uses the data contained in the TableModel. I'd suggest making a custom field that accepts this TableModel object. You could also use a GridFieldManager and add LabelFields to it for each cell of the TableModel object.