gpt4 book ai didi

user-interface - 黑莓 - 在屏幕上设置字段位置?

转载 作者:行者123 更新时间:2023-12-04 22:52:52 24 4
gpt4 key购买 nike

我想将我的领域定位在指定的位置。

最佳答案

基本上设置任何 经理之间的现场位置,你应该:

  • 覆盖 sublayout
  • 套装 layoutChild 每个经理领域
  • 套装setPositionChild 每个经理领域
  • 使用 setExtend正确调整尺寸管理器

  • 删除了无效的 ImageShack 链接

    扩展经理代码:
    class CustomVerticalManager extends VerticalFieldManager {
    LabelField mText1 = new LabelField("top");
    LabelField mText2 = new LabelField("bottom");

    public CustomVerticalManager() {
    add(mText1);
    add(mText2);
    }

    public int getPreferredHeight() {
    return Display.getHeight();
    }

    public int getPreferredWidth() {
    return Display.getWidth();
    }

    protected void sublayout(int width, int height) {
    width = getPreferredWidth();
    height = getPreferredHeight();

    int fieldWidth = mText1.getPreferredWidth();
    int fieldHeight = mText1.getPreferredHeight();
    layoutChild(mText1, fieldWidth, fieldHeight);
    int xPos = (width - fieldWidth) >> 1;
    int yPos = 0;
    setPositionChild(mText1, xPos, yPos);

    fieldWidth = mText2.getPreferredWidth();
    fieldHeight = mText2.getPreferredHeight();
    layoutChild(mText2, fieldWidth, fieldHeight);
    xPos = (width - fieldWidth) >> 1;
    yPos = height - fieldHeight;
    setPositionChild(mText2, xPos, yPos);
    setExtent(width, height);
    }
    }

    使用示例:
    class Scr extends MainScreen {
    CustomVerticalManager mManager = new CustomVerticalManager();

    public Scr() {
    add(mManager);
    }
    }

    也可以看看
    Wireless - How to : Create a custom layout manager for a screen
    Blackberry - fields layout animation

    关于user-interface - 黑莓 - 在屏幕上设置字段位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1761602/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com