我正在使用setCallback创建一个列表,但它没有创建。我的drawLsitrow方法没有被调用。一切都很好,除了那个列表。就像我在使用时测试一样 System.out.println(“打印标题为 * ** * ** * ** * “+的getTitle);它在我的代码中只打印了4次而不是在drawListrow中打印。 所以请他;请把我......关于...... 提前谢谢..........
package listPackage;
public class AddsToFavouriteScreen extends MainScreen
{
//declare the global variable
static String Text;
int numberCount=0;
public int index;
//static Vector latitude;
public String latitude;
Vector title1= new Vector();
String location1;
String employer1;
String Description1;
public FavouriteList getFavouriteList = new FavouriteList( );
class FavouriteList extends ListField implements ListFieldCallback {
public Vector rows = new Vector();
public FavouriteList() {
super(0, ListField.MULTI_SELECT);
}
static int count = -1;
Vector gettitle;
public void listCreate(Vector recievedTitle) {
setRowHeight(60);
setEmptyString("It is Empty!", DrawStyle.HCENTER);
setCallback(this);
gettitle = new Vector(recievedTitle.size());
for (int i = 0; i< recievedTitle.size(); i++) {
gettitle.addElement(recievedTitle.elementAt(i));
System.out.println("Print Title is **********************"+gettitle);
}
System.out.println("Print Title is **********************"+gettitle);
FontFamily fontFamily[] = FontFamily.getFontFamilies();
//Font font2 = fontFamily[1].getFont(Font.BOLD, 15);
Font font3 = fontFamily[1].getFont(Font.PLAIN, 15);
for (int index = 0; index < recievedTitle.size(); index++) {
TableRowManager row = new TableRowManager();
RichTextField titleText = new RichTextField(recievedTitle
.elementAt(index).toString(), DrawStyle.ELLIPSIS);
titleText.setFont(font3);
row.add(titleText);
System.out.println("Print Title is **********************"+gettitle);
rows.addElement(row);
}
setSize(rows.size());
System.out.println("Print rows **********************"+gettitle);
}
public void drawListRow(ListField listField, Graphics g, int index, int y,
int width) {
FavouriteList list = (FavouriteList) listField;
TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);
rowManager.drawRow(g, 0, y, width, 200);
System.out.println("Print Title is **********************"+gettitle);
}
public 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());
System.out.println("Print Title is **********************"+gettitle);
subpaint(g);
g.setColor(0x00CACACA);
g.drawLine(0, 0, getPreferredWidth(), 0);
g.popContext();
}
protected void sublayout(int width, int height) {
int fontHeight = Font.getDefault().getHeight();
int preferredWidth = getPreferredWidth();
Field field = getField(0);
layoutChild(field, 300, fontHeight + 1);
setPositionChild(field, 10, 5);
/*Field field = getField(0);
layoutChild(field, 100, fontHeight + 1);
setPositionChild(field, 5, 5);
field = getField(1);
layoutChild(field, 250, fontHeight + 1);
setPositionChild(field, 100, 5);*/
setExtent(preferredWidth, getPreferredHeight());
}
public int getPreferredWidth() {
return Display.getWidth();
}
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;
}
}