I am making a list that has persons and every ones rate as a cell background the list gives every cell the same rate background but when scroll the list up or down the cell that I'm dragging take it's real rate background but other cells stay the same rate background image I'm using nokia s40 full touch emulator This is the code that I'm using for the cell renderer
list.setRenderer(new ListCellRenderer() {
public Component getListFocusComponent(List list) {
// TODO Auto-generated method stub
return null;
}
public Component getListCellRendererComponent(List list,
Object value, int index, boolean isSelected) {
String rate = "";
rate = Transportation.getDriverRate(value.toString(),
CityListForm.selectedCity);
rate = (Integer.parseInt(rate)) > 25 ? "" + 5 : ""
+ Integer.parseInt(rate) / 5;
rate = "/" + rate + ".png";
Image image = null;
Label label = null;
try {
image = (Image.createImage(rate));
System.out.println(rate);
} catch (IOException e) {
e.printStackTrace();
}
label = new Label();
label.getStyle().setBgImage(image);
label.setText(value.toString());
label.getStyle().setAlignment(RIGHT);
label.setTextPosition(RIGHT);
Style style = label.getStyle();
style.setBgColor(16777215);
style.setFgColor(0);
label.setPreferredH(42);
return label;
}
});
Use List.setMutableRendererBackgrounds(true);