我想将我的领域定位在指定的位置。
最佳答案
基本上设置任何 经理之间的现场位置,你应该:
删除了无效的 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/