You re going to have to keep track of what rows have been clicked (and therefore have images which are hidden) and which have not. I would use an array of booleans to do this.
Override the keyDown method in your CustomListField and use getSelectedIndex to figure out which row is currently selected.
阁下的DelListRow方法指出,清单现场被作为参数通过,把这个数据带回海关,并采用一种称为“RowClicked(intindex)”的新方法,该方法可回收该行是否被点击,因此,应当利用或没有适当的手图。
大致如下:
public class CustomListField extends ListField implements ListFieldCallback{
private static final int TOTAL_ROWS = 10; //total number of rows in list
private boolean[] clickedRows = new boolean[TOTAL_ROWS];
public CustomListField(){
//do all your instantiation stuff here
}
public boolean keyDown(int keycode, int time){
int currentlySelectedRow = getSelectedIndex();
//toggle the state of this row
clickedRows[currentlySelectedRow] = !clickedRows[currentlySelectedRow];
//consume the click
return true;
}
public boolean isRowClicked(int index){
return clickedRows[index];
}
public void drawListRow(ListField listField, Graphics graphics, int index,
int y, int width) {
CustomListField customListfield = (CustomListField) listField;
//check whether this row is clicked
if(customListfield.isRowClicked(index)){
//draw the state when the row is clicked
} else {
//draw the row when the row is not clicked
}
}
}