2010-11-24 132 views
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); 
    } 
} 

回答

0

如果你要在measureRowList一个NullPointerException,我会首先关注的地方是该方法的源代码,看空值被取消引用什么。它看起来像你没有包括该方法的来源,但。

+0

这种方法的核心平台的原生。并没有看到它的实施。 – 2010-11-26 11:01:39