在 BlackBerry 中将按钮放在屏幕底部并带有背景
我一直在努力在我的应用程序中获取背景图像,并在屏幕底部的图像上排列四个按钮。下面我展示了我用来实现它的代码。
HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(new ButtonField("1", FIELD_BOTTOM));
manager.add(new ButtonField("2", FIELD_BOTTOM));
manager.add(new ButtonField("3", FIELD_BOTTOM));
manager.add(new ButtonField("4", FIELD_BOTTOM));
mWidth = Display.getWidth();
mHeight = Display.getHeight();
final Bitmap backgroundBitmap = Bitmap.getBitmapResource("intro.png");
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH |HorizontalFieldManager.USE_ALL_HEIGHT)
{
//Override the paint method to draw the background image.
public void paint(Graphics graphics)
{
//Draw the background image and then call super.paint
//to paint the rest of the screen.
graphics.drawBitmap(0, 0, mWidth, mHeight,backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
BackGroundImage.add(manager);
add(BackGroundImage);
问题是,如果我将 Field_BOTTOM 放在horizontalFieldManager 中,现在我无法将按钮放置在屏幕底部。
I have been working to get a background image in my application and also arrange four buttons at the bottom of the screen to the image. Below I show the code which I have used to achieve it.
HorizontalFieldManager manager = new HorizontalFieldManager();
manager.add(new ButtonField("1", FIELD_BOTTOM));
manager.add(new ButtonField("2", FIELD_BOTTOM));
manager.add(new ButtonField("3", FIELD_BOTTOM));
manager.add(new ButtonField("4", FIELD_BOTTOM));
mWidth = Display.getWidth();
mHeight = Display.getHeight();
final Bitmap backgroundBitmap = Bitmap.getBitmapResource("intro.png");
HorizontalFieldManager BackGroundImage = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH |HorizontalFieldManager.USE_ALL_HEIGHT)
{
//Override the paint method to draw the background image.
public void paint(Graphics graphics)
{
//Draw the background image and then call super.paint
//to paint the rest of the screen.
graphics.drawBitmap(0, 0, mWidth, mHeight,backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
BackGroundImage.add(manager);
add(BackGroundImage);
The thing is that now I am not able to place the buttons at the bottom of the screen if I put a Field_BOTTOM is the horizontalFieldManager.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以这样做,在 HorizontalFieldManager 中将其参数设置为 FIELD_BOTTOM
,然后将按钮直接添加到此 HorizontalFieldManager 中,然后使用
setStatus(Field status)
MainScreen 方法,即You can do like this, in your HorizontalFieldManager set its parameter as FIELD_BOTTOM
then add your buttons directly to this HorizontalFieldManager and then use
setStatus(Field status)
MainScreen method i.e.