2
我有一个自定义对象列表字段与实施滚动例程。moveFocus不叫
public int moveFocus(int amount, int status, int time) {
invalidate(getSelectedIndex());
int unused = super.moveFocus(amount, status, time);
return Math.abs(unused) + 1;
}
public boolean navigationMovement(int dx, int dy, int status, int time) {
if (dy > 0) {
if (selectedIndex < getSize() - 1) {
setSelectedIndex(selectedIndex + 1);
}
} else if (dy < 0) {
if (selectedIndex > 0) {
setSelectedIndex(selectedIndex - 1);
}
}
return true;
}
当我使用拨轮滚动时,滚动工作正常,但在带轨迹球的设备上启动应用程序时,滚动工作正常。我发现这个问题存在于框架方法moveFocus中,当我使用轨迹球滚动时,根本不会调用它。
这是否定义它是否消耗或不消耗。返回true消费,否则返回false。因此,在您的moveFocus可以处理它之前,您的导航移动正在消耗该事件。你误解了Field的文档。这只是说,如果这个函数没有被覆盖,但总是不会消耗事件的子类。这可能有点不清楚,但它的功能正如你所期望的那样。 – Fostah 2009-10-08 12:13:25
我想你没有仔细阅读问题描述。当我返回TRUE时,我得到不同的行为,这取决于我使用TRACKWHEEL还是TRACKBALL。 如果TRACKWHEEL调用moveFocus,则另一方面,如果TRACKBALL是事件的来源,则不会调用moveFocus。 – nixau 2009-10-08 12:21:50
当我在'navigationMovement'方法中返回FALSE时'moveFocus'根本不被调用! – nixau 2009-10-08 12:23:33