// Get this screen's main manager (VerticalFieldManager)
final Manager mainManager = getMainManager();
// Create a RichList which will be added to the provided manager
final RichList richList = new RichList(mainManager, true, 4, 0);
// Set the focus policy for the RichList
richList.setFocusPolicy(TableController.ROW_FOCUS);
// Populate the RichList with data from text file
while (deviceData.hasMoreTokens()) {
final String modelNumber = deviceData.nextToken().trim();
final StringBuffer displayName = new StringBuffer(modelNumber);
final String modelName = deviceData.nextToken().trim();
if (!modelName.equals(modelNumber)) {
displayName.append(" (");
displayName.append(modelName);
displayName.append(")");
}
final String os = deviceData.nextToken().trim();
final String imageFileName = modelNumber + ".png";
final Bitmap bitmap = Bitmap.getBitmapResource(imageFileName);
final String year = deviceData.nextToken().trim();
final String interfaces = deviceData.nextToken().trim();
// Add data to the RichList
final Object[] rowObjects = new Object[5];
rowObjects[BITMAP] = bitmap;
rowObjects[DISPLAY_NAME] = displayName.toString();
rowObjects[OS] = os;
rowObjects[YEAR] = year;
rowObjects[INTERFACES] = interfaces;
richList.add(rowObjects);
}
richList.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
// Display selected device in a pop up dialog
final TableModel tableModel = richList.getModel();
final Object[] objArray =
(Object[]) tableModel.getRow(richList.getFocusRow());
final Dialog dialog =
new Dialog(Dialog.D_OK,
(String) objArray[DISPLAY_NAME], 0,
(Bitmap) objArray[BITMAP], 0);
dialog.doModal();