4
我想将我的领域放在指定的位置。黑莓 - 在屏幕上设置字段的位置?
我想将我的领域放在指定的位置。黑莓 - 在屏幕上设置字段的位置?
基本设置任何场位置amoung经理,你768,16:
去除死ImageShack的链接
extanded经理代码:
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
很好的回答。 RIM实际上在5.0 API中有一个名为AbsoluteFieldManager的新类,但由于某种原因,它从最新的beta版中删除了它。 – 2009-11-19 22:16:30