我想在登录屏幕的末尾添加一个位图栏,在该位图栏的顶部,我想放置到按钮(确定和取消)。我怎么做?我应该将该栏添加到某种背景模板
public class EcraTemplate extends MainScreen {
private HorizontalFieldManager hm;
private MyLabelField title;
private BitmapField logotipo;
public EcraTemplate (long style) {
super(style);
....
logotipo = new BitmapField...
title = new LabelField
hm = new HorizontalFieldManager();
hm.add(logotipo);
//fill screen
this.add(hm);
我如何在这里添加带有按钮的位图?
答案 0 :(得分:1)
您可以使用Manager.setBackground()
来完成此操作。
HorizontalFieldManager hm = new HorizontalFieldManager();
Bitmap bmp = Bitmap.getBitmapResource("background.png"); //whatever your background image name is
hm.setBackground(BackgroundFactory.createBitmapBackground(bmp);
之后,您可以像平常一样添加按钮。如果您发现您的HFM尺寸不正确,可以将其修改为
final Bitmap bmp = Bitmap.getBitmapResource("background.png");
HorizontalFieldManager hm = new HorizontalFieldManager(){
protected void sublayout(int width, int height) {
super.sublayout(width, height);
setExtent(Math.min(bmp.getWidth(), width), Math.min(bmp.getHeight(), height));
}
};
hm.setBackground(BackgroundFactory.createBitmapBackground(bmp);
这样它就是你背景图片的尺寸。