黑莓手机 - 自定义为本循环Horizo​​ntalFieldManager [英] BlackBerry - Custom centered cyclic HorizontalFieldManager

查看:149
本文介绍了黑莓手机 - 自定义为本循环Horizo​​ntalFieldManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想创建一个自定义的周期性水平管理器,它会工作如下。将控制几个字段按钮,其中的按钮将总是被定位,以使聚焦的按钮将在屏幕的中间。由于这是一个周期性的管理者,一旦焦点移到左边或右边按钮,它会移动到屏幕的中心,所有的按钮将相应移动(与最后一个按钮将成为第一个给它一个循环和无休止的名单感觉)

Trying to create a custom cyclical horizontal manager which will work as follows. It will control several field buttons where the buttons will always be positioned so that the focused button will be in the middle of the screen. As it is a cyclical manager once the focus moves to the right or left button, it will move to the center of the screen and all the buttons will move accordingly (and the last button will become the first to give it an cyclic and endless list feeling)

不知道如何解决这个问题?

Any idea how to address this?

我试图通过实施根据所需要的布局,对齐按钮的定制管理器这样做。每次moveFocus()被调用我删除所有字段(deleteAll()),并以正确的顺序重新添加它们。
不幸的是这是行不通的。

I tried doing this by implementing a custom manager which aligns the buttons according to the required layout. Each time moveFocus() is called I remove all fields (deleteAll() ) and add them again in the right order. Unfortunately this does not work.

推荐答案

从KB <使用Horizo​​ntalButtonFieldSet类href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/How_to_-_Implement_advanced_buttons,_fields,_and_managers.html?nodeid=2406256&vernum=0\"相对=nofollow>如何 - 实现高级按钮,字段和管理者:

class CentricHManager extends HorizontalButtonFieldSet {
    int focusedFieldIndex = 0;

    public void focusChangeNotify(int arg0) {
        super.focusChangeNotify(arg0);
        int focusedFieldIndexNew = getFieldWithFocusIndex();
        if (focusedFieldIndexNew != focusedFieldIndex) {
            if (focusedFieldIndexNew - focusedFieldIndex > 0)
                switchField(0, getFieldCount() - 1);
            else
                switchField(getFieldCount() - 1, 0);
        }
    }

    private void switchField(int prevIndex, int newIndex) {
        Field field = getField(prevIndex);
        delete(field);
        insert(field, newIndex);
    }

    public void add(Field field) {
        super.add(field);
        focusedFieldIndex = getFieldCount() / 2;
        setFieldWithFocus(getField(focusedFieldIndex));
    }
}

这篇关于黑莓手机 - 自定义为本循环Horizo​​ntalFieldManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆