In my blackberry app I have a manager that controls the layout of the fields for my screen. This is the standard way of doing things when you want a custom layout.
在我的黑莓应用程序中,我有一个管理器来控制屏幕的字段布局。当您需要自定义布局时,这是执行操作的标准方法。
Now, one of the "fields" that I'm using is itself a Manager that lays out a series of controls nicely. Call this "field" the "summaryField" as it summarizes data for me. This all renders out nicely.
现在,我正在使用的其中一个“字段”本身就是一个管理器,可以很好地布局一系列控件。将此“字段”称为“summaryField”,因为它为我汇总了数据。这一切都很好地呈现出来。
However, when I override the isFocusable()
member of "summaryField", I start getting a null pointer exception.
但是,当我覆盖“summaryField”的isFocusable()成员时,我开始获得空指针异常。
Anyone have an idea of why this exception is being thrown?
任何人都知道为什么抛出这个异常?
public class SummaryField extends Manager
{
protected void drawFocus(Graphics graphics, boolean on) {
super.drawFocus(graphics, on);
}
protected void onFocus(int direction) {
super.onFocus(direction);
}
protected void onUnfocus() {
super.onUnfocus();
}
public boolean isFocusable() {
return true;
}
}
1 个解决方案
#1
1
If I had to guess, I'd say that your Manager probably doesn't contain any focusable fields in it, and therefore your hardcoded "true" return value for isFocusable() is lying about the true state of the SummaryField. Remember that Managers themselves can't have "focus", just the fields within it.
如果我不得不猜测,我会说你的管理器可能不包含任何可聚焦字段,因此isFocusable()的硬编码“true”返回值是关于SummaryField的真实状态。请记住,管理者自己不能“专注”,只有其中的字段。
#1
1
If I had to guess, I'd say that your Manager probably doesn't contain any focusable fields in it, and therefore your hardcoded "true" return value for isFocusable() is lying about the true state of the SummaryField. Remember that Managers themselves can't have "focus", just the fields within it.
如果我不得不猜测,我会说你的管理器可能不包含任何可聚焦字段,因此isFocusable()的硬编码“true”返回值是关于SummaryField的真实状态。请记住,管理者自己不能“专注”,只有其中的字段。