Try something like this
Code:
class MyGrid extends ListField implements ListFieldCallback {
private MyData[] data;
public MyGrid(MyData[] data) {
setCallback(this);
this.data = data;
}
public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
MyData row = (MyData) get(listField, index);
// draw some stuff
Bitmap b = Bitmap.getBitmapResource(row.icon);
g.drawBitmap(0, y, 16, 16, b, 0, 1);
int indent = 24;
g.drawText(row.string, indent, y, Graphics.ELLIPSIS, width - indent);
}
public Object get(ListField listField, int index) {
return data[index];
}
public int getPreferredWidth(ListField listField) {
return Display.getWidth();
}
public int indexOfList(ListField listField, String prefix, int start) {
return getSelectedIndex();
}
public int getSize() {
return (data != null) ? data.length : 0;
}
class MyData {
String string;
String icon;
}
}