这是我的自定义列表字段。
public class Custom_ListField extends ListField implements ListFieldCallback {
private Vector rows;
private LabelField titletext, datetext, categorytext;
private Bitmap bg = Bitmap.getBitmapResource("list_bar.png");
public Custom_ListField(String title[], String date[], String category[]) {
super(0, ListField.MULTI_SELECT);
setRowHeight(80);
setCallback(this);
Background background = BackgroundFactory.createBitmapBackground(bg);
setBackground(background);
rows = new Vector();
for (int x = 0; x < title.length; x++) {
TableRowManager row = new TableRowManager();
titletext = new LabelField(title[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
titletext.setFont(Font.getDefault().derive(Font.BOLD, 20));
row.add(titletext);
datetext = new LabelField(date[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
datetext.setFont(Font.getDefault().derive(Font.BOLD, 15));
row.add(datetext);
categorytext = new LabelField(category[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
//categorytext.setMargin(0, 0, 0, 100);
categorytext.setFont(Font.getDefault().derive(Font.BOLD, 15));
row.add(categorytext);
rows.addElement(row);
}
setSize(rows.size());
}
public void drawListRow(ListField listField, Graphics g, int index, int y,
int width) {
Custom_ListField list = (Custom_ListField) listField;
TableRowManager rowManager = (TableRowManager) list.rows
.elementAt(index);
rowManager.drawRow(g, 0, y, width, list.getRowHeight());
}
private class TableRowManager extends Manager {
public TableRowManager() {
super(0);
}
public void drawRow(Graphics g, int x, int y, int width, int height) {
layout(width, height);
setPosition(x, y);
g.pushRegion(getExtent());
subpaint(g);
g.popContext();
}
protected void sublayout(int width, int height) {
int fontHeight = Font.getDefault().getHeight();
int preferredWidth = getPreferredWidth();
Field field = getField(0);
layoutChild(field, preferredWidth - 16, fontHeight + 1);
setPositionChild(field, 5, 5);
field = getField(1);
layoutChild(field, 150, fontHeight);
setPositionChild(field, 5, fontHeight + 5);
field = getField(2);
layoutChild(field, 150, fontHeight);
setPositionChild(field, preferredWidth - 155, fontHeight + 5);
setExtent(preferredWidth, getPreferredHeight());
}
public int getPreferredWidth() {
return Graphics.getScreenWidth();
}
public int getPreferredHeight() {
return getRowHeight();
}
}
public Object get(ListField listField, int index) {
return null;
}
public int getPreferredWidth(ListField listField) {
return 0;
}
public int indexOfList(ListField listField, String prefix, int start) {
return 0;
}
}
如果点击然后在哪里设置push screen
?