Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 关注ListField?_Blackberry - Fatal编程技术网

Blackberry 关注ListField?

Blackberry 关注ListField?,blackberry,Blackberry,我在屏幕上添加了两个列表字段 但是在焦点的改变上,它并没有横向地进入第二个列表 我想把焦点放在列表1到列表2上,让它水平移动。在两个水平管理器中组织4个字段时,我们遇到了类似的问题。从右上角字段向下滚动将我们带到左上角而不是右下角,因为移动首先在水平管理器中滚动 我们最终实现了自己的管理器,用于添加和定位字段(而不是水平管理器),然后覆盖管理器的功能,如中所述,根据移动控制哪个字段获得焦点。例如: if (dx < 0) { getField(focusedIndex - 1)

我在屏幕上添加了两个列表字段 但是在焦点的改变上,它并没有横向地进入第二个列表


我想把焦点放在列表1到列表2上,让它水平移动。

在两个水平管理器中组织4个字段时,我们遇到了类似的问题。从右上角字段向下滚动将我们带到左上角而不是右下角,因为移动首先在水平管理器中滚动

我们最终实现了自己的管理器,用于添加和定位字段(而不是水平管理器),然后覆盖管理器的功能,如中所述,根据移动控制哪个字段获得焦点。例如:

if (dx < 0)
{
    getField(focusedIndex - 1).setFocus();
}

对于navigationMovement,使用dx和dy的值以及当前具有焦点的字段的索引来确定下一个要接收焦点的字段。如果没有焦点更改,只需返回false而不更改焦点,例如,当从最左侧的字段向左移动时,您可能希望保持在同一字段上,而不是环绕。

公共布尔导航移动(int-dx、int-dy、int-status、int-time)
{
int focusedIndex=getFieldWithFocusIndex();
if(dx<0)
{
getField(focusedIndex-1).setFocus();
}
如果(dx>0),则为else
{
getField(focusedIndex+1).setFocus();
}
else if(dy<0)
{
getField(focusedIndex-2).setFocus();
}
如果(dy>0),则为else
{
getField(focusedIndex+2).setFocus();
}
其他的
返回false;
返回true;
}


我希望这有帮助:)

还有另一种解决方案,您可以使用任何管理器结构:

protected boolean navigationMovement(int dx, int dy,
            int status, int time) {

        Field focusedIndex = ThisScreen.getFieldWithFocus().getLeafFieldWithFocus();
        if (focusedIndex == YourFocusableField)
        { 
           //any needed settings here
           if (dx < 0)
           {
               anyField.setFocus();
           }
           else if (dx > 0)
           {
               anyField.setFocus();
           }
           else if (dy < 0)
           {
               anyField.setFocus();
           }
           else if (dy > 0)
           {
               anyField.setFocus();
           }
           else
              return false;

           return true;
        }
    }
受保护的布尔导航移动(int-dx,int-dy,
整数状态,整数时间){
Field focusedIndex=ThisScreen.getFieldWithFocus().getLeafFieldWithFocus();
if(focusedIndex==YourFocusableField)
{ 
//这里有需要的设置吗
if(dx<0)
{
anyField.setFocus();
}
如果(dx>0),则为else
{
anyField.setFocus();
}
else if(dy<0)
{
anyField.setFocus();
}
如果(dy>0),则为else
{
anyField.setFocus();
}
其他的
返回false;
返回true;
}
}

但在这种情况下,您需要对每个可用字段执行此操作

您能提供一个简短的代码片段吗?@amit我在答案的正文中添加了示例代码和注释。
protected void sublayout(int width, int height)
{
    int count = getFieldCount();
    Field field;
    for (int i = 0; i < count; i++)
    {
        field = getField(i);
        layoutChild(field, field.getWidth(), field.getHeight());
        setPositionChild(field, xPositionOfButton, yPositionOfButton);
    }

    setExtent(width, height);
}
public boolean navigationMovement(int dx, int dy, int status, int time)
{
    int focusedIndex = getFieldWithFocusIndex();

    if (dx < 0)
    {
        getField(focusedIndex - 1).setFocus();
    }
    else if (dx > 0)
    {
        getField(focusedIndex + 1).setFocus();
    }
    else if (dy < 0)
    {
        getField(focusedIndex - 2).setFocus();
    }
    else if (dy > 0)
    {
        getField(focusedIndex + 2).setFocus();
    }
    else
        return false;

    return true;
}
protected boolean navigationMovement(int dx, int dy,
            int status, int time) {

        Field focusedIndex = ThisScreen.getFieldWithFocus().getLeafFieldWithFocus();
        if (focusedIndex == YourFocusableField)
        { 
           //any needed settings here
           if (dx < 0)
           {
               anyField.setFocus();
           }
           else if (dx > 0)
           {
               anyField.setFocus();
           }
           else if (dy < 0)
           {
               anyField.setFocus();
           }
           else if (dy > 0)
           {
               anyField.setFocus();
           }
           else
              return false;

           return true;
        }
    }