public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) { Object[] childImagePair = (Object[]) this.get(listField, index); Child child = (Child) childImagePair[0]; Bitmap image = (Bitmap) childImagePair[1]; drawStatusBox(listField, graphics, index, child); drawChildImage(graphics, listField, index, image); graphics.setColor(Color.BLACK); graphics.setFont(titleFont); // Takes 5 params 1:display text, 2:horizontal position, // 3: vertical position, 4: flags, 5: text display width graphics.drawText( (String) child.getField("name"), firstRowPosition, y, (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP), screenWidth - firstRowPosition - 4); int yStartForText = y + (this.getFont()).getHeight() + 1; drawFieldRow(graphics, width, child, yStartForText, "age"); yStartForText = yStartForText + (this.getFont()).getHeight() + 1; drawFieldRow( graphics, width - secondRowPosition - 4, child, yStartForText, "last_known_location"); yStartForText = yStartForText + (this.getFont()).getHeight() + 1; graphics.drawLine( 0, (index * listField.getRowHeight()), width, (index * listField.getRowHeight())); }
private void drawFieldRow( Graphics graphics, int width, Child child, int yStartForText, String field) { graphics.setFont(rowFont); graphics.drawText( (String) child.getField(field), secondRowPosition, yStartForText, (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP), width); }