Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.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的labelField中水平滚动_Blackberry_Horizontal Scrolling_Labelfield - Fatal编程技术网

如何在Blackberry的labelField中水平滚动

如何在Blackberry的labelField中水平滚动,blackberry,horizontal-scrolling,labelfield,Blackberry,Horizontal Scrolling,Labelfield,我想在标签字段中水平滚动 我正在自定义GridField管理器中添加此LabelField。下面是自定义GridField管理器的代码 public class CustomGridFieldManager extends Manager { private int[] columnWidths; private int columns; private int allRowHeight = -1; public CustomGridFieldManager(int columns, lo

我想在标签字段中水平滚动

我正在自定义GridField管理器中添加此LabelField。下面是自定义GridField管理器的代码

public class CustomGridFieldManager extends Manager {
private int[] columnWidths;
private int columns;
private int allRowHeight = -1;


public CustomGridFieldManager(int columns, long style) {
    super(style);
    this.columns = columns;
}


public CustomGridFieldManager(int[] columnWidths, long style) {
    super(style);
    this.columnWidths = columnWidths;
    this.columns = columnWidths.length;

}

public CustomGridFieldManager(int[] columnWidths, int rowHeight, long style) {
    this(columnWidths, style);
    this.allRowHeight  = rowHeight;
}

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

    int focusIndex = getFieldWithFocusIndex();
    while(dy > 0) {
        focusIndex += columns;
        if (focusIndex >= getFieldCount()) {
            return false; // Focus moves out of this manager
        }
        else {
            Field f = getField(focusIndex);
            if (f.isFocusable()) { // Only move the focus onto focusable fields
                f.setFocus();
                dy--;
            }
        }
    }
    while(dy < 0) {
        focusIndex -= columns;
        if (focusIndex < 0) {
            return false;
        }
        else {
            Field f = getField(focusIndex);
            if (f.isFocusable()) {
                f.setFocus();
                dy++;
            }
        }
    }

    while(dx > 0) {
        focusIndex ++;
        if (focusIndex >= getFieldCount()) {
            return false;
        }
        else {
            Field f = getField(focusIndex);
            if (f.isFocusable()) {
                f.setFocus();
                dx--;
            }
        }
    }
    while(dx < 0) {
        focusIndex --;
        if (focusIndex < 0) {
            return false;
        }
        else {
            Field f = getField(focusIndex);
            if (f.isFocusable()) {
                f.setFocus();
                dx++;
            }
        }
    }
    return true;
}

protected void sublayout(int width, int height) {
    int y = 0;
    if (columnWidths == null) {
        columnWidths = new int[columns];
        for(int i = 0; i < columns; i++) {
            columnWidths[i] = width/columns;
        }
    }
    Field[] fields = new Field[columnWidths.length];
    int currentColumn = 0;
    int rowHeight = 0;
    for(int i = 0; i < getFieldCount(); i++) {
        fields[currentColumn] = getField(i);
        layoutChild(fields[currentColumn], columnWidths[currentColumn], height-y);
        if (fields[currentColumn].getHeight() > rowHeight) {
            rowHeight = fields[currentColumn].getHeight();
        }
        currentColumn++;
        if (currentColumn == columnWidths.length || i == getFieldCount()-1) {
            int x = 0;
            if (this.allRowHeight >= 0) {
                rowHeight = this.allRowHeight;
            }
            for(int c = 0; c < currentColumn; c++) {
                long fieldStyle = fields[c].getStyle();
                int fieldXOffset = 0;
                long fieldHalign = fieldStyle & Field.FIELD_HALIGN_MASK;
                if (fieldHalign == Field.FIELD_RIGHT) {
                    fieldXOffset = columnWidths[c] - fields[c].getWidth();
                }
                else if (fieldHalign == Field.FIELD_HCENTER) {
                    fieldXOffset = (columnWidths[c]-fields[c].getWidth())/2;
                }

                int fieldYOffset = 0;
                long fieldValign = fieldStyle & Field.FIELD_VALIGN_MASK;
                if (fieldValign == Field.FIELD_BOTTOM) {
                    fieldYOffset = rowHeight - fields[c].getHeight();
                }
                else if (fieldValign == Field.FIELD_VCENTER) {
                    fieldYOffset = (rowHeight-fields[c].getHeight())/2;
                }

                setPositionChild(fields[c], x+fieldXOffset, y + fieldYOffset);
                x += columnWidths[c];
            }
            currentColumn = 0;
            y += rowHeight;
        }
        if (y >= height) {
            break;
        }
    }
    int totalWidth = 0;
    for(int i = 0; i < columnWidths.length; i++) {
        totalWidth += columnWidths[i];
    }
    setExtent(totalWidth, Math.min(y, height));
}
我加上这样的标签

lbl_CustEmail = new LabelField("Customer Email", LabelField.FOCUSABLE);
        lbl_CustEmail.setFont(label_font);

        value_CustEmail = new LabelField(": " +trandtail[0].getFromEmail());
        value_CustEmail.setFont(label_font);

   gfm_transactioninfo.add(lbl_CustEmail);
   gfm_transactioninfo.add(value_CustEmail);

如果有人对如何水平滚动有任何想法,请帮助我。提前感谢。

通过自定义栅格视图,您可以在标签字段前后添加一个FocusableNullField。一旦焦点位于第一个空字段上,您就可以水平滚动到下一个焦点BlenullField,并显式地使labelfield可滚动。

尝试您希望触摸板用户如何滚动,当您覆盖navigationMovement?是否有特定原因导致您不能将标签简单地放在设置为水平滚动的FieldManager中?ie
gfm\U交易信息添加(经理)
@Kevin-这种方法的一个问题是,他在GFM中覆盖了navigationMovement,那么他将如何在非触摸屏设备上滚动管理器中的字段?我认为这不会奏效,我认为添加NullFields只意味着你可以关注开始和结束,而不是滚动。您可以使LabelField可聚焦,以在开始时达到与NullField类似的效果,甚至可以使用RichTextField替换LabelField,该字段保持“插入符号”,因此在这方面可以滚动。有许多类似的选项,但对我来说,问题是它们都不能在提供导航移动覆盖的轨迹板设备上工作。因此,OP没有回答我的问题。
lbl_CustEmail = new LabelField("Customer Email", LabelField.FOCUSABLE);
        lbl_CustEmail.setFont(label_font);

        value_CustEmail = new LabelField(": " +trandtail[0].getFromEmail());
        value_CustEmail.setFont(label_font);

   gfm_transactioninfo.add(lbl_CustEmail);
   gfm_transactioninfo.add(value_CustEmail);