Hello Every one
I am using following code for generating custom objectlistfield its working fine, but the problem is , the screen where i am using this custom objectlistfield has 3 buttonfield, but when i click the buttonfield all the time the objectlist field is being selected, i dont no what is going wrong.. please help me out... its urgent...
public CustomObjectListField( String[] detailsStr, String[] nameStr, String [] details, String[] distance){
this.detailsStr = detailsStr;
this.nameStr = nameStr;
this.details = details;
this.distance = distance;
screenWidth = Display.getWidth();
firstrowPostion = (screenWidth) - (screenWidth - 20);
secondRowPosition = (screenWidth)- (screenWidth - 100);
try {
FontFamily alphaSerifFamily = FontFamily.forName("BBAlpha Serif");
titleFont = alphaSerifFamily.getFont(Font.PLAIN,3,Ui.UNITS_mm);
row1Font = alphaSerifFamily.getFont(Font.PLAIN,2,Ui.UNITS_mm);
row2Font = alphaSerifFamily.getFont(Font.PLAIN,2,Ui.UNITS_mm);
}
catch (Exception e){
UiApplication.getUiApplication().pushScreen(new CustomDialog("Error in importing Font"));
}
}
// We are going to take care of drawing the item.
public void drawListRow(ListField listField, Graphics graphics,int index, int y, int width) {
if(listField.getSelectedIndex() == index) {
graphics.setColor(Color.CORNSILK);
graphics.fillRect(0,(index* listField.getRowHeight()),width, listField.getRowHeight());
graphics.setColor(0x000000);
invalidate();
}
graphics.setColor(Color.BLACK);
graphics.drawText(index+1+". ", 0,y, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setColor(Color.GREEN);
graphics.setFont(titleFont);
graphics.drawText(nameStr[index],firstrowPostion, y, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
int newY = y + (this.getFont()).getHeight() + 1; // y start for text
graphics.setColor(Color.BLACK);
graphics.setFont(row1Font);
graphics.drawText(status,firstrowPostion, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setColor(Color.GREEN);
graphics.setFont(row2Font);
graphics.drawText(detailsStr[index],secondRowPosition, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setColor(Color.BLACK);
newY = newY + (this.getFont()).getHeight() + 1;
graphics.setFont(row1Font);
graphics.drawText(Phase,firstrowPostion, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setFont(row2Font);
graphics.drawText(details[index],secondRowPosition, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
newY = newY + (this.getFont()).getHeight() + 1;
graphics.setFont(row1Font);
graphics.drawText(distanceStr,firstrowPostion, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setFont(row2Font);
graphics.drawText(distance[index],secondRowPosition, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
newY = newY + (this.getFont()).getHeight() + 1;
graphics.setFont(row1Font);
graphics.drawText(contact,firstrowPostion, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
graphics.setFont(row2Font);
graphics.drawText(contactString,secondRowPosition, newY, (DrawStyle.LEFT|DrawStyle.ELLIPSIS|DrawStyle.TOP), width);
newY = newY + (this.getFont()).getHeight() + 1;
graphics.drawLine(0,(index* listField.getRowHeight()), GlobalData.SCREEN_WIDTH, (index* listField.getRowHeight()));
}
}