Hello,
how do I delete just a single item from a ListField?
I tried this but it doesn't work:
Code:
public class ListCallback implements ListFieldCallback {
public Vector listElements = new Vector();
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
String text = (String)listElements.elementAt(index);
g.drawText(text, 0, y, 0, w);
}
public Object get(ListField list, int index) {
return listElements.elementAt(index);
}
public int indexOfList(ListField list, String p, int s) {
//return listElements.getSelectedIndex();
return listElements.indexOf(p, s);
}
public int getPreferredWidth(ListField list) {
return Graphics.getScreenWidth();
}
public void insert(String toInsert, int index) {
listElements.insertElementAt(toInsert, index);
}
public void erase() {
listElements.removeAllElements();
}
public void eraseAt(int index) {
listElements.removeElementAt(index);
}
}
well this was just the declaration, now the code to delete the selected item:
Code:
myCallback.eraseAt(myList.getSelectedIndex());
why doesn't it work?
is there a way to delete the selected item from the list?
thank you guys in advance!
Murene