I am using drawListRow to repaint the autocomplete field, but I'm having trouble to set it's field height, here is my code:
autoCustomer = new AutoCompleteField(custList, style){
public void drawListRow(ListField clistField, Graphics g,
int index, int y, int width) {
BasicFilteredListResult result = (BasicFilteredListResult)
autoCustomer.get(clistField, index);//);
if (result == null)
return;
String[] stringArray = parseMessage(result._object.toString(), Font.getDefault().derive(Font.PLAIN),fontSize, width-30);
int i;
int yCoord = 0;
int xCoord = 0;
//int rowHeight = (stringArray.length * fontHeight)+3;
clistField.setRowHeight((stringArray.length * fontHeight)+3); //already did this, but it won't work
System.out.println(stringArray.length);
g.setFont( Font.getDefault().derive(Font.PLAIN,fontSize,Ui.UNITS_px));
for(i = 0;i<stringArray.length;i++){
yCoord = y + (fontHeight*(i));
if(i>0)
xCoord = 20;
g.drawText(stringArray[i].trim() , xCoord, yCoord, (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP ), width-20);
}
}
What should I do to make proper row height with this autocomplete ?
I unintentionally found the answer, the first argument is index of the list and the second is the height. The documentation doesn't mention about this, I only found setRowHeight(int arg0, int arg1) in the documentation of class in eclipse. The solution is simple
clistField.setRowHeight(index,(stringArray.length * fontHeight)+3);