0
我發展JDE 4.6.1下一個黑莓手機項目。的問題是,將項目添加到列表中時,一個NullPointerException從方法拋出measureListRow黑莓ObjectListField
NPE調用堆棧:
CustomerListField(ObjectListField).measureListRow(ListField, int, int) CustomerListField(ListField).layout(int, int) CustomerListField(ObjectListField).layout(int, int) VList(Manager).layoutChild(Field, int, int)
注:
- db_.getDataAccess() - 數據庫
- getListCount - 讓項目的數量在列表
- CustomerListItem - 列表項的結構
及相關代碼:
public class CustomerListField extends ObjectListField implements ListFieldCallback, ChangeListener {
private PagedDataFetcher dataFetcher = new CustomerListPagedDataFetcher();
…
public CustomerListField() {
try {
super.set(new Object[db_.getDataAccess().getListCount()]);
} catch (Throwable e) {
}
}
public void drawListRow(ListField listField, Graphics g, int index, int y,
int width) {
CustomerListItem currentRow = (CustomerListItem) get(listField, index);
…
}
public Object get(ListField list, int index) {
try {
return dataFetcher.getRowAtIndex(index);
} catch (Throwable e) {
return null;
}
}
// To obtain the data
public class CustomerListPagedDataFetcher extends PagedDataFetcher {
protected Vector get(int from, int to) throws Exception {
return DataAccess.getDataAccess().getLists(from, to);
}
}
/**
* layout for list
*/
final class VList extends VerticalFieldManager {
private final ObjectListField list;
int maxHeight = Display.getHeight() - getFont().getHeight() * 2 - 5;
VList(ObjectListField list) {
super(Manager.VERTICAL_SCROLLBAR | Manager.VERTICAL_SCROLL);
this.list = list;
}
public int getPreferredHeight() {
return 45 * list.getSize();
}
protected void sublayout(int width, int height) {
super.sublayout(width, height);
setExtent(width, maxHeight);
}
}
這種方法的核心平臺的原生。並沒有看到它的實施。 – 2010-11-26 11:01:39